2

When editing the following yaml with Vim:

countries:
  - country:
      name: France

I can comment out line 2 with :2s/^/#Enter (Case 1). The result is as expected:

countries:
#  - country:
      name: France

However, when I tried to do the same with 2G^hhi#ESC (Case 2), the result will be different :

countries:
        #- country:
      name: France

Extra 8 spaces are now present before #.

What causes this behavior, and how do I achieve the same behavior as Case 1, while using keystrokes somewhat more similar to Case 2 ?

1 Answers1

1

^ in normal-mode vim means "the first non-whitespace column of the line"

0 in normal-mode vim means "the first column of the line"

Thus, 2G0i# would go to line 2, column zero, in insert mode, and type #.