New answers tagged


If PHP is available, add the tool jf as a JSON Formatter by Composer: $ composer global require codegear/json-formatter Then Format current file: :%!jf % Or add a keymap in vimrc: nnoremap <Leader>jf :%!jf %<CR>


Found it... In a moment of serendipity, I discovered that a comment block in a different file was not reformatted! The only difference was this file used a different set of 'ftplugin' and 'syntax' configuration. After a LONG bit of detective work I finally traced the solution to changing my comment settings from... :setl comments=b:\| to... :setl ...


Unfortunately, I can't find anything to force Vim to exclude some text region from the manual formatting. But at least the following script should do this: " format a line range except the lines starting with a 'comment' string function! MyFormat(comment) range " go to the firstline; then mark the lastline execute a:firstline ';' a:lastline "k'" ...

Top 50 recent answers are included