Vim command for incrementing numbers sequentially.
my_array[1] = 0;
my_array[2] = 0;
my_array[3] = 0;
my_array[4] = 0;
my_array[5] = 0;
my_array[6] = 0;
my_array[7] = 0;
If you want to increment numbers inside my_array
1. with cursor on the first 0 in the first line

2. blockwise select with Ctrl-V
- enter blockwise-visual mode
 - and select all wanted number
 
Vim keys are will be...
<Ctrl-V>
6j  # or simply jjjjjj
vfor visual mode,Vfor line-visual mode,Ctrl-Vfor blockwise visual mode. For more information, read:help ctrl-v
Then you'll got selected numbers
3. increment with g Ctrl-A
<Ctrl-A>is add count to the number or alphabetic character.g <Ctrl-Aeach one will be incremented if several lines are selected
You can see help text in
:help ctrl-a
Vim key strokes will be
g
<Ctrl-a>
Then, boom!
All in one
So, all keystrokes will be (NO enter, newline is just for readability
It suppose to start from first line, first character (m)
f0  # find 0
<Ctrl-V>
6j
g
<Ctrl-a>
Here's whole gif

'tools > vim' 카테고리의 다른 글
| 리눅스 man을 vim으로 열어보자 (0) | 2021.01.06 | 
|---|---|
| vimgrep 기본 사용법 (0) | 2021.01.05 | 
| ipython에서 vim 단축키 사용하기 (0) | 2021.01.03 | 
| vim help text 새 탭에서 보기 (0) | 2021.01.02 | 
| vim resize split size: vim 창 크기 조절하기 (0) | 2021.01.01 |