vim command

ctrl+f Page down (Page down key)
ctrl+b Page up (Page Up key)
ctrl+d Half page down
ctrl+u Half page up
+ Next line
- previous row
<num>space Move num characters backward, 20 space bar => move 30 characters backward
H Move to the first character on the first line of the screen
M Move to the first character in the middle of the screen
L Move to the first character of the last line on the screen
G Move to the first character of the last line of the document
<num>G Move to the specified number of rows 20G => Move to 20 rows
gg Move to the first row, equivalent to 1G
<num>Enter Move down num lines 20 and press Enter => cursor moves down 20 lines
/key Search down keywords
?key Search keywords upward
n Find next
N Find the previous
:n1,n2s/key1/key2/gc

:1,50s/php/java/gc

From line 1 to line 50, search for php and replace with java

c Prompt information:

    y replaces a single

    n skip a single

    Y replace all

    N do not replace all

:n1,$s/key1/key2/gc

:1,$s/php/java/gc

From line 1 to the last line, search for php and replace with java

:$s/key1/key2/gc

:$s/php/java/gc

Full text search PHP replaced with java

x Delete the character under the cursor
X Delete the character before the cursor
<num>x 20x delete 20 characters backward from the cursor position
<num>X 20X Start from the character before the cursor and delete 20 characters forward
dd Delete the line where the cursor is
<num>dd 2dd start from the line where the cursor is and delete 2 lines down
d1G Starting from the cursor position, delete all previous lines
dG Starting from the cursor position, delete all subsequent lines
d$ Starting from the cursor position, delete the content after the line
d0 Starting from the cursor position, delete the line before the cursor
yy Copy the line where the cursor is
<num>yy 20yy=>From the line where the cursor is located, copy 20 lines
y1G

Starting from the line where the cursor is, copy all the previous content

yG Start from the line where the cursor is, and copy everything behind
y0 From the cursor position, copy the content in front of the cursor
and $ 从光标所在位置开始,复制光标后面内容
p 向下粘贴
P 向上粘贴
J 合并下一行 删除回车键
ctrl+r 前进
u 撤回
. 重复上一个动作
   
i

从光标所在位置切换输入模式

I 从光标所在行的开始位置切换输入模式
a

从光标所在位置切换输入模式

A 从光标所在行的结束位置切换输入模式
o 在光标的下一行开始输入
O 在光标的上一行开始输入
r 替换模式,一个字符
R 替换模式,持续性,Esc退出模式
   
:w 保存不退出
:w! 强制保存
:q 退出,有修改文件,退不了
:q! 强制退出
:wq 保存并退出
:wq! 强制保存并退出
ZZ 保存退出 == :wq
ZQ 强制退出 == q!
:w 文件名 另存为 文件
:r 文件名 从光标的下一行,载入另一份文件
:n1,n2 w 文件名

:1,100 w 2.txt

将第1行到100行内容另存为2.txt

   
:set nu 显示行号
:set nonu 隐藏行号

 

Guess you like

Origin blog.csdn.net/lows_H/article/details/109118444
Recommended