Vim NerdCommenter: adding a new filetype in vimrc
is there a way to define a new filetype comment for NerdCommenter in .vimrc?
It's开发者_运维百科 already working, but it would be more easy to backup config, if I can place this into .vimrc directly.
Thanks.
NERDCommenter is able to parse commentstring
option, so if you have only one possible comment marker, you may put the following to the vimrc:
augroup SetCMS
autocmd FileType ocaml let &l:commentstring='(*%s*)'
augroup END
This does not allow you to specify alternative commenting style (like /*%s*/
and //%s
for C++). In this case you should contact author of NERDCommenter and he will add your filetype into next release. This is the example of filetype support request.
The recommended approach from the NERDCommenter help documentation seems to actually be to add the following to your .vimrc:
let g:NERDCustomDelimiters = {
\ 'someFiletypeOfYours': { 'left': '#'}
\ }
You might also consider contributing a pull request to the project on GitHub, so as to have your new language and its comment delimiters be recognized by default by the plugin.
精彩评论