Basic Operation Open File
vim [option] file +n. :打开文件后,让光标处于第n.行的行首,+默认行尾 \\ vim +5 file 打开file并让光标处在第5行
Enter insert mode
i \\ 在光标处输入 I \\ 当前光标行的行首输入 a \\ 在光标所在处后面输入 A \\ 在当前光标所在行的行尾输入 o \\ 光标下方开一个新行 O \\ 光标上方开一个新行
Command mode basic operation
x \\ 剪切光标处字符,n.x剪切光标起始处n.个字符 p \\ (小写p)如果缓冲区为整行,在光标下方粘贴,否则在光标所 \\ 在后面粘贴,xp可以实现字符换位 P \\ (大写P)如果缓冲区为整行,在光标上方粘贴,否则在光标后 \\ 面粘贴 ~ \\ 转换文档中光标所在处字母大小写 J \\ 删除当前行后的换行符 r \\ 替换光标所在处字符,如rm将光标处字符换成m R \\ 进入replace模式,此模式下输入的字符会替换光标所 \\ 在位置的字符 ctrl+f,b:向下或向上翻一屏 ctrl+d,u:向下或向上翻半屏 u \\ 撤销最近的更改 ctrl+r \\ 重做最后的撤销 n.u \\ 撤销之前的n.次更改 U \\ 撤销光标落在这行的所有对此行更改、 . \\ 重复上一个操作 n. \\ 重复上一个操作n次
Extended mode or trailing line mode
Command mode Press ":" Colon into extended mode
W \ \ Save q \ \ exit Wq \ \ Save Exit q! \ \ Force quit, do not save r filename \ \ read the file to the current file W filename \ \ Write the file to the specified file!command \ \ Execute the command r!command \ \ Read-in command output ①. Address delimitation start position, end position and operation such as 1y copy the first row 2,4d delete the second row to line fourth 2,+4y copy the second row to the sixth row. Represents the current line $ last line% full text, equivalent to 1,% start and end positions you can use regular expressions such as:/[0-9]/,/[0-9]/d \ \ To delete the first match to the containing number Rows to the second horse \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Match to a row containing a number the action command that can be used includes the D,y,w file (the rows within the range are stored as specified) r file \ \ (Inserts the specified file content at the specified location) ②. Find alternate find:/pattern down (pattern is what you're looking for)? pattern up find n,n with command in the same direction or in the opposite direction Match (enter matching command and press n,n) to replace the format: s/find content/replace content/modifier find content can use patterns (regular) instead of using patterns but you can use a back reference, and you can use & to refer to the entire contents of the previous lookup Modifier: I: Ignore case g: global substitution, by default each row replaces only the first occurrence of the GC: global substitution, replace before asking for a delimiter in the find replacement/can be replaced with the @ #等字符 For example: Delete the white space character from the beginning of the file: [EMAIL&NBSp;protected]^[[:space:]]\[email protected]@g Add a # 1,[email protected]^[[:space at the beginning of the file with all whitespace characters: ]]@#\[email protected]
And finally, there's a picture.
This picture contains command mode most commands, if you can remember, absolutely installed force, and the original image, too big can not upload, to a connection, see can download Https://share.weiyun.com/5YxLhPX
It's enough to know about vim.