Skip to content

Add example to override = mappings in codefmt docs #12

Open
@dbarnett

Description

@dbarnett

Some filetypes have terrible default indenting logic (using the = mapping) and also have a formatter fast enough and robust enough to drop in as the formatting implementation for the = mapping. You can do this by adding something like the following to your vimrc:

function s:AddCodefmtEqualMapping() abort
  " Replace all the various ={motion} keys to codefmt
  nnoremap <buffer> = :set opfunc=codefmt#FormatMap<CR>g@
  nnoremap <buffer> == :FormatLines<CR>
  vnoremap <buffer> = :FormatLines<CR>
endfunction
augroup codefmt_equal
  autocmd FileType cpp,proto call s:AddCodefmtEqualMapping()
augroup END

We should add an example like this into the codefmt help and explain what to expect + caveats when you use it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions