Assuming the lindent
can be invoked like a normal filter (:%! {cmd}
), the following commands will process the current buffer and reset the modification flag (so that the file appears as unchanged):
:%!lindent
:setlocal nomodified
You may want to :setlocal nomodifiable
, too, to avoid that you accidentally persist the reformatted file.
Put these commands into ~/.vim/after/ftplugin/c.vim
. (This requires that you have :filetype plugin on
; use of the after directory allows you to override any default filetype settings done by $VIMRUNTIME/ftplugin/c.vim
.) Alternatively, you could define an :autocmd FileType c ...
directly in your ~/.vimrc
, but this tends to become unwieldy once you have many customizations.