tpope / vim-commentary

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

commenting in html/jsp file #9

Open losingkeys opened 12 years ago

losingkeys commented 12 years ago

Is it possible to configure commentary to use // or /**/ inside <script> tags in html files and <!-- --> elsewhere? If so, it'd be nice to have this kind of thing in jsp/php/erb files as well.

graywh commented 12 years ago

Maybe you would be interested in http://github.com/tomtom/tcomment_vim

losingkeys commented 12 years ago

That's fairly nice; however it can't take a # like commentary, and it seems to add more mappings than commentary.

tpope commented 12 years ago

This sounds handy, but really, really complicated to implement, and I'm pretty convinced it wouldn't be worth it for just this one use case.

tpope commented 12 years ago

To elaborate a bit, the sole purpose of commentary is temporarily commenting out code. In the jsp/php/erb case, you can use <%# %> comments (or whatever) to comment out HTML, JavaScript, and CSS just fine, even if it is a bit uglier. So I'm not worried about that. It's just JavaScript within plain HTML that's the use case.

Also, I'd argue that dumping big chunks of JavaScript directly into an HTML document is poor form, but that's just my opinion, not commentary's.

suy commented 11 years ago

I wrote a small plugin that piggybacks on the syntax highlighting groups to automatically change the value of commentstring. So far seems to work well for me, and it's really simple and customizable (or so I hope, my knowledge of VimL is pretty small).

I hope @tpope can give it a look, since I mostly wrote it for being used with commentary, and I really want to learn more vim script. :-) Feel free to be blunt!

https://github.com/suy/vim-context-commentstring

Asheq commented 6 years ago

For the benefit of others who come across this issue: In Issue #60, @vheon has some solutions, most notably inline_edit.vim

robertjk commented 6 years ago

The other use case is Vue.js single file components which have JavaScript, HTML and CSS all in one file (with .vue extension). I'm working on them now and have problems with commenting stuff using this plugin.

caw plugin uses something called context filetype.

MartMcMahon commented 6 years ago

@robertjk I came here for the same reason. @suy 's plugin worked perfectly out of the box!

hp4k1h5 commented 4 years ago

The other use case is Vue.js single file components which have JavaScript, HTML and CSS all in one file (with .vue extension). I'm working on them now and have problems with commenting stuff using this plugin.

i believe suy's plugin works for this now thanks suy!

himat commented 4 years ago

@robertjk do you think caw is better than this plugin for commenting? I'm wondering which one to use.

robertjk commented 4 years ago

@himat I'm using vim-commentary right now. caw felt too complicated for me. This plugin is super simple and does everything I need other than context comments. caw on the other hand has context comments, but other than that does the same than this plugin only using a lot more commands and keybindings which I found overcomplicated.