Vim icon indicating copy to clipboard operation
Vim copied to clipboard

[n]gc does comment out n+1 lines instead of n.

Open OdysseusOperator opened this issue 1 year ago • 2 comments

Describe the bug [n]gc does comment out n+1 lines instead of n.

To Reproduce Steps to reproduce the behavior:

create a file with following python file (if it is txt gc will not work):

def test():
    print('a')
    print('b')
    print('c')
    print('d')

go to the line with print('b') Switch into normal mode in the middle of the file. 2gc<Down>

Expected behavior gc would comment out two lines.

What happened instead ? gc commented out 3 lines

Vim for VSCode version: v1.27.2

OdysseusOperator avatar Mar 04 '24 00:03 OdysseusOperator

I can't reproduce the problem you described. Actually, I need to use [n]gcc to comment n lines, [n]gc simply does nothing.

Maybe you're using a custom keymapping or something...?

shinohara-rin avatar Mar 28 '24 00:03 shinohara-rin

Sorry i forgot that you need to use a direction. It is 2gc<DOWN ARROW>

OdysseusOperator avatar Mar 28 '24 13:03 OdysseusOperator

Sorry i forgot that you need to use a direction. It is 2gc

What do you mean? As stated above, 2gc doesn't do anything, and 2gcc works fine for me.

J-Fields avatar Jun 30 '24 22:06 J-Fields

Go into one of the first lines and try 2gc[Arrow Down]

OdysseusOperator avatar Jul 01 '24 12:07 OdysseusOperator

[count]gc<Down> is equivalent to [count]gcj, which comments [count]+1 lines by design, like other commands (dj deletes 2 lines).

J-Fields avatar Jul 01 '24 14:07 J-Fields