Add support for code formatting
Is it in the plan for code format?
Yes, I do have plans to add support eventually. I'll keep this issue open to track.
@Cosson2017 use vim's default functionality equalprg , formatprg, formatexpr.
For example, for c/c++, install clang-format and put the following code in .vimrc
if &ft == c
setlocal formatprg=clang-format\ --style='Webkit'
setlocal equalprg=clang-format\ --style='Webkit'
endif
and then either use gq + text object(ap,aw,...) to format selected block or = to format the whole file.
@Piping
Just FYI (not trying to be Mr. Smarty pants here), the right way to set formatprg, or any other filetype-specific options, is either through autocmd in your vimrc:
" File: ~/.vimrc
augroup myvimrc
autocmd!
autocmd FileType c,cpp setlocal formatprg=clang-format\ --stype='Webkit'
autocmd FileType c,cpp setlocal equalprg=clang-format\ --stype='Webkit'
augroup END
or by using the after/ftplugin/ directory:
" File: ~/.vim/after/ftplugin/c.vim
setlocal formatprg=clang-format\ --style='Webkit'
setlocal equalprg=clang-format\ --style='Webkit'
@bfrg Thanks! I did put all my code environment steup in a function and then call the function from autocmd! But It is a good point.