Hugo
Hugo

Reputation: 2189

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.

Upvotes: 4

Views: 1337

Answers (2)

glaforge
glaforge

Reputation: 524

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.

Upvotes: 2

ZyX
ZyX

Reputation: 53674

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.

Upvotes: 2

Related Questions