NERD comment: how to comment on a range

I am using NERD commentator

Say I want to comment on lines 78 through 172. This is what I do. I calculate the difference. This is 94. put my cursor on line 78 and then me: 94, c space

So I will comment on 94 lines starting at line 78.

I don't like the calculations I need to do. I was hoping to convey a range similar to

78,172 to comment on code from lines 78 to 172. I missed something.

Looking at the popularity of this plugin, there seems to be a better way to comment and uncomment.

+9
vim
Sep 03 '09 at 18:11
source share
4 answers

I would do (in visual mode) :78v172G to select and highlight lines 78 through 172, and then simply ,c<space> .

+11
Sep 03 '09 at 18:19
source share

It doesn't seem like NERDCommenter supports ranges, so Alex's answer will be correct, but it has a typo - it must be 78GV172G to select (note - don't precede : , followed by your comment function (in my case \cc ).

+6
Feb 01 '11 at 18:59
source share

Enter visual mode <ctrl> + V using the arrow keys, highlight the lines you want, then /c<space> (you may have another key for comments).

+3
Jun 01. '14 at
source share

Sexual Comment Mode C

By default, line ranges only work with visual highlighting + <leader>cc tested on 2.5.2, as mentioned at: https://stackoverflow.com/a/2126258/

But first of all, I want to highlight "sexy mode" comments in this answer with <leader>cs , which generate nice multi-line comments in C.

For example, if you start with:

 This is ac style sexy comment So there! 

then <leader>cs from the visual selection will convert it to:

 /* This is ac style sexy comment * So there! */ 

And you can also switch to non-compact mode by adding to your .vimrc :

 let g:NERDCompactSexyComs = 0 

which works as follows:

 ------------------------------------------------------------------------------ *'NERDCompactSexyComs'* Values: 0 or 1. Default 0. Some people may want their sexy comments to be like this: > /* Hi There! * This is a sexy comment * in c */ < As opposed to like this: > /* * Hi There! * This is a sexy comment * in c */ 

Another related format that may be of interest is the "Minimal Comment Map", available with <leader>cm which produces:

 /* Hi There! This is a sexy comment in C */ 

I could not find my favorite style, unfortunately:

 /* Hi There! * This is a sexy comment * in c */ 

so I opened: https://github.com/scrooloose/nerdcommenter/issues/379

0
Jun 09 '19 at 12:38 on
source share



All Articles