Reputation: 16242
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?
Upvotes: 6
Views: 1501
Reputation: 3915
As of the following PR to add hooks, NERDCommenter allows one to configure a comment style that is specific to the language block within the file.
This was built to support .vue
files that, not unlike regular HTML files, have a <template>
(html) block, a <script>
and a <style>
block, each requiring a unique commenting syntax.
You can find the vue
sample implementation in the Hooks section of the docs. Should you choose to do so, it may help guide you in writing one for framework-agnostic HTML files.
Upvotes: 0
Reputation: 12633
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).
Upvotes: 2