When editing html in Vim, I'll write the class name of the section that I am working on like this:


It is untagged plain text.

I'll call tcomment to comment that out. What I expect to have happen is this:

<!-- mid-med -->

Instead I get this:

<!-- mid&#45;med -->

tcomment is converting the plain-text hyphen into html character code.

Is there anyway to prevent tcomment from doing this?

I searched "help:tcomment" but I couldn't find or make sense of anything.

I could just create the comment code first then type in the text but that's counter-intuitive and messing up my workflow.

Any help would be appreciated.

  • 1
    Why don't you try the issue tracker?
    – mMontu
    Oct 8, 2015 at 17:51
  • I can reproduce the problem on a Debian with vim 7.4 (both terminal and gVim). That might not be the best answer possible but you could give a try to nerdCommenter which doesn't have this problem.
    – statox
    Oct 8, 2015 at 21:27
  • I suppose this is, because nested comments are not allowed in HTML/XML. But best would be to use the issue tracker. Aug 16, 2019 at 7:00

2 Answers 2


Add this to a file ~/.vim/ftplugin/html.vim:

let g:tcomment#replacements_xml = {}
  • That do solves the problem but could you detail a little more your answer to explain why it works please? :-)
    – statox
    Oct 9, 2015 at 6:52
  • 1
    @statox Not really. It works because the code uses g:tcomment#replacements_xml for translations. Now, why does the code do that for HTML files, is a good question. A question you'd have to ask tcomment's author though. Personally I suspect it's a bug, but the author might disagree. :) Oct 9, 2015 at 7:12
  • my pwd was "~/.vim/bundle/html5.vim/ftplugin/html.vim". Solution worked like a charm. Thank you Oct 9, 2015 at 17:19

Just updating the answers to this question, as I encountered this annoyance and I found a solution.

Edit ~/.vim/bundle/tcomment_vim/autoload/tcomment.vim (line ~152):

                "\     '-': '&#45;',
                "\     '&': '&#38;',
                \     '-': '-',
                \     '&': '&',

I.e., simply replace - with - ...

Restart Vim.

Details here: https://github.com/tomtom/tcomment_vim/issues/253

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.