DEV Community

Discussion on: 3 Ways to Comment Out Blocks of Code in vi

Collapse
 
moopet profile image
Ben Sinclair

I use a plugin to do this because different languages have different requirements for comments and I'm lazy). I use commentary but there are a few that all do much the same thing.

Out of your options, I prefer #3, but I'd also consider using a macro and repeating it n times if the comments required changing the start and end of the line, like in CSS.

Using ctrl-smilieface to enter pedantic mode I feel the urge to point out that #3 is Vim only and not available in Vi.

Collapse
 
grepliz profile image
Liz Lam

I haven't had a lot of experiences with different plugins, but I will have to check out commentary.

So funny, yes. I tend to use the words 'vi' and 'vim' interchangeably and I was debating if I should make that distinction on this blog.

True story, I used vi proper for almost 10 years and for 8 of those years at work on an old RedHat Workstation distribution. A time came where all our work machines got upgraded to Ubuntu and I ended up with vim on my machine (I think it was vim-tiny). I wasn't familiar with visual mode. Everytime I accidentally hit CTRL + v, I would quickly ESC out because I didn't know what it was doing.

3 months ago, I decided to finally make the small effort to learn visual mode.

I love how you can learn new things all the time even in the tools you've been using forever!

Thanks for the comments!