简体   繁体   中英

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM