Programmer's favorite editor: Vim
first figure out the three modes of vim:
1. Command mode: Enter the "Vim file name" in the Linux terminal to enter the command mode, but cannot enter the text.
2. Edit mode: Press I in command mode will enter the editing mode, you can write the program, press ESC to return to the command mode.
3. Last line mode: In command mode, press: Enter the last line mode, there will be a colon in the lower left corner, you can type the command and execute.
The following is a simple analysis of three modes:
here are some common tips for vim:
O: Insert the next line in the current row and enter edit mode
O: Insert a row on the current line and enter edit mode
R: Replace the character at the cursor
R: Replace the current character and its characters until you press [ESC]
W Save gg=g Automatic alignment syntax
Set NU: Sets the line number
Set Nonu: Cancel line number
V: Enter the visual
YY: Copy when moving forward
YYY: The current line and the following three rows
P: Paste
Vim use
O: Insert the next line in the current row and enter edit mode
O: Insert a row on the current line and enter edit mode
R: Replace the character at the cursor
W Save gg=g Automatic alignment syntax
R: Replacement mode
YY: Copy when moving forward
YYY: The current line and the following three rows
P: Paste
NYW: copy n words
U: Undo
D: Cut
DD: Cut one line
NDD: Cut n rows
X: Delete the character of the cursor, equivalent to the [delete] function key
X: Delete cursor before character, equivalent to [Backspace]
DD: Delete the line where the cursor is located
DB: Delete cursor at the beginning of the word
DW: Delete the cursor at the end of the word
S: replaces the specified number of characters with the input text starting at the current cursor position
S: Deletes the specified number of rows and replaces them with the input text
D0: Delete to the beginning of the line
D: Delete the cursor at the end of the line
d+}: Delete cursor to next blank line
DG: Delete cursor at end of file
L: Current screen bottom row
H: Current screen header line
M: Current screen middle row
$: Current End of line
0/^: Current beginning of the line
W: Next word Header
B: Previous word
: line number is transferred to the specified line
}: Next blank line
{: Previous blank line
%: Auto Match find
A: Append to the back
VSP + file name Vertical split screen
CTRL+WW: Different screen switching
/+ Find what: Start finding
N: Next target
N: Previous target
59,60s/source/target/g replace all from 59 to 60
%s/Source/destination/g full text replacement
R filename: Test the file at the cursor
csdn:
http://blog.csdn.net/qq_38646470/article/details/79643000
Vim usage tips (INSERT, delete, find, copy, paste, cut)