Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NERDCommenter: Giving me js comments in an html file

Tags:

vim

I am editing an html file but when I invoke the NERD commenter it is adding js comments (/*...*/) rather than html ones (<!-- ... -->). I have just installed the latest version (2.3.0) and am using vim 7.3.

How can I fix this?

Thanks

EDIT: Digging into this more, I found in the source code of NERD_commenter.vim a list of all the supported filetypes. Oddly, xhtml and html do not appear on the list:

\ 'htmlcheetah': { 'left': '##' },
\ 'htmldjango': { 'left': '<!--','right': '-->', 'leftAlt': '{#', 'rightAlt': '#}' },
\ 'htmlos': { 'left': '#', 'right': '/#' },

I feel this cannot be right somehow. Also, bonus question: Assuming you get html comments to work, can this plugin detect when the cursor is between <script> tags and change the comment to js comments when it is?

like image 605
Jonah Avatar asked Apr 26 '12 22:04

Jonah


1 Answers

Digging into the NERD-commenter code, it seems that when the filetype is not in it's list, it extracts it from a vim option named &commentstring. My guess would be that some other plugin/configurations has changed &commentstring for html files(probably to better support javascript comments).

like image 144
Idan Arye Avatar answered Sep 30 '22 21:09

Idan Arye