vim-commentary icon indicating copy to clipboard operation
vim-commentary copied to clipboard

Html/XML commenting

Open szebenyib opened this issue 9 years ago • 2 comments

Hi!

Would it be possible to escape existing comments in html/xml differently than it is implemented now? The problem is that the generated xml code is invalid if comments already exist in the file, because -- characters in a commented part are invalid.

Example: <!-- something --> becomes <!-- <1-- something --1> -->

It would be nice if the following happened: Example: <!-- something --> becomes <!-- <1__ something __1> -->

This renders the page invalid and invalidity completely denies rendering of the file.

szebenyib avatar Mar 01 '16 12:03 szebenyib

@szebenyib Same problem here, vim-commentary is great, but for xml a little bit useless because of not-valid nested-comments. I wrote a small workaround, maybe it is helpfull!

augroup Xml
command! ValidComment execute "normal! mtvat\<esc>`<:'<,'>s/<1!--/<1!__/ge\<cr>:'<,'>s/--1>/__1>/ge\<cr>:nohlsearch\<cr>"
command! ValidUncomment execute "normal! mtvat\<esc>`<:'<,'>s/<1!__/<!--/ge\<cr>:'<,'>s/__1>/-->/ge\<cr>:nohlsearch\<cr>"
nnoremap <leader>vc :ValidComment<cr>
nnoremap <leader>vu :ValidUncomment<cr>
augroup END

@tpope Sorry for my bad knowledge of VimL, I'm just a beginner with Vim, I'm sure there is a better solution!

5202 avatar Apr 10 '16 17:04 5202

@tpope I appreciate if you provide commentstring for xml.

vrkansagara avatar Nov 26 '21 09:11 vrkansagara