Delete lines from current line to first line on screen

dH (in command mode)

Input special characters

Special characters like ‘^M’, ‘^@’ have special meaning in vim.
If you want to type in those special characters or search them in vim,
you will need to follow steps below.

Ctrl+v Ctrl+Shift+m ---> ^M
Ctrl+v Ctrl+Shift+2 ---> ^@

make a increased number by line in vim

I need to create some lines which contains a sequence of increased number line by line.

Way 0:

seq -f %1.f 978711100001 978711130000 >num.txt

Way 1:

In vim's command mode, input "r !seq 1 12".
:r !seq 1 10
cat t
1
2
3
4
5
6
7
8
9
10

Way 2:

#!/bin/sh

for ((i=100001;i<=130000;i++))
do
   echo "978711$i">>/tmp/num.txt
done

Way 3:

  • copy lines with same number, eg “1”
    cat t
    1
    1
    1
    1
    1
    1
    1
    1
    1
    1
    1
    1
    1
    
  • In vim’s command mode, input “let i=0 g/1/s//=i/ let i=i+1” . “1” is the number you copied to every line.
:let i=0 | g/1/s//\=i/ | let i=i+1
// After that command, you will get number you needed
cat t
0
1
2
3
4
5
6
7
8
9
10
11
12

  • Our target is Record an action, change “0” to “0 0”, and repeat that action. like:
    cat t 
    0 0
    1 1
    ......
    12 12
    

    Recoard an action, change “0 0” to “<vcpupin vcpu=’0’ cpuset=’0’ />” and repeat that action. ```sh cat t

……

```

Way 4:

插入模式下,按顺序输入 ctrl-r,=,range(1,100),回车