Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim NERD Commenter \c deletes the line instead of toggling comments

The following works fine for me, it will comment out the current line:

<Leader>cc

but according to the docs (https://github.com/scrooloose/nerdcommenter#usage) if I want to toggle comments I do:

<Leader>c

which deletes the current line for me.

Am I missing something?

like image 707
Liam Avatar asked Nov 06 '14 20:11

Liam


People also ask

How do I uncomment a line in Vim?

A few regular Vim commands do not work with my setup on Windows. Ctrl + v and Ctrl + q are some of them. I later discovered the following methods worked to uncomment lines. The following approaches remove the # symbol and preserve indents. Move the cursor to the first comment (arrows or h, j, k, l ). Then apply one of the following techniques:

How to add a comment to a Vim file?

There is this life changing plugin by tpope called vim-commentary Install via Vundle (or Pathogen I guess). Type Commentary here :<,'>Commentary and press Enter. Boom. Your done bud. Could this have just been an edit of the Tim Pope answer by Jim Stewart? I mark the first and last lines (ma and mb), and then do :'a,'bs/^# //

How do I comment out a line in gvim?

Hit Ctrl + q in GVIM or Ctrl + v in VIM, then go down to select first character on the lines to comment out. Then press c, and add the comment character. Uncommenting works the same way, just type a space instead of the comment character. c deletes the first character as well.

How to remove all comments from a file in Linux?

If you want to remove all commented lines from a file, then you will have to remove the lines starting with ‘#’. Assume, you want to remove all lines that match/contain specific pattern – then the command is similar to the above one. For example:


1 Answers

This command is actually <Leader>c<space>, not just <Leader>c (see this issue; this is not properly displayed in the readme).

like image 136
jonafato Avatar answered Sep 25 '22 06:09

jonafato