How to use NERDComment plugin for Vim
Asked Answered
W

2

3

I am new to Vim itself but I am trying to adopt this editor for my needs. I installed NERDComment plugin as described and have it listed in my :scriptnames. But I don't understand from description and this page how to use it.
I have filetype plugin on in VIM/_vimrc and when I do ,cc (as I understand default is ,) it happens to work as cc* - Delete [count] lines [into register x] and start insert |linewise|.*
Please give me basic 'step-by-step' guide on [count]<leader>cc |NERDComComment| for example. I am pretty sure I just don't understand some kind of Vim concept so sorry if this question is lame.

Washerman answered 4/8, 2014 at 13:35 Comment(6)
do you have filetype plugin on in your vimrc? if you tried <leader>cc what was happened? please tell what's your problem?!Siusan
@Siusan Yes, I have filetype plugin on in VIM/_vimrc and when I do ,cc (as I understand default <leader> is ,?) it happens to work as "["x]cc Delete [count] lines [into register x] and start insert |linewise|."Washerman
@Washerman default <leader> is \ (backslash)Fannyfanon
Thank you @Fannyfanon that worked as it should! Why is that not listed in manual? Or am I getting this wrong?Washerman
@Washerman are you sure it is not listed in manual? it is a kind of RTFM thing. :h mapleader you can see If "mapleader" is not set or empty, a backslash is used instead.Siusan
@Siusan I apologized for stupid questions in the topic post. I am first-day vim user and by far got only as far as vimtutorial. I will sure fulfill my knowledge in time. :)Washerman
P
4

Step by step

  • [count] => number of lines to be commented, can be ommited
  • <leader> => leader key, \ by default. Many people change it to ,.
  • cc => just cc

Visual mode

Instead of count you can go into visual mode with v or V, select the lines you want to comment and then use \cc

About leader key

To know which one is your leader key you can use :echo mapleader, if that gives you Undefined variable the mapleader will be the default ('\').

You can check :help leader in vim for more info.

Pastelki answered 4/8, 2014 at 14:9 Comment(0)
P
0

when you are in visual mode: select the lines to be commented and type ,cc.

when you are in normal mode: type 5,cc for eg if you want to comment the next 5 lines.

Note: I have assumed the leader key to be a comma(,) - check yours using :echo leader

Peplos answered 4/8, 2014 at 13:54 Comment(2)
Not working for me, behaves like "["x]cc Delete [count] lines [into register x] and start insert |linewise|." :(Washerman
check your leader key with :echo leader and substitute it for the comma(,).Peplos

© 2022 - 2024 — McMap. All rights reserved.