tpope / vim-commentary

commentary.vim: comment stuff out
http://www.vim.org/scripts/script.php?script_id=3695
5.91k stars 215 forks source link

Html/XML commenting #65

Open szebenyib opened 8 years ago

szebenyib commented 8 years ago

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.

5202 commented 8 years ago

@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!

vrkansagara commented 3 years ago

@tpope I appreciate if you provide commentstring for xml.