Vim three modes: Command mode, insert mode, bottom line mode. Use ESC, I,: Toggle mode.
vim [path/] Target file name : Open if it exists, new and open if it does not exist.
Basic Steps : 1. Vim hello.c 2. Type I 3. Edition 4. Type [ESC] 5. Type: Wq Save exit
Command mode : for copy, paste, delete, insert, undo, move, etc.
move : H, J, K, l--move left, bottom, top, and right cursors (J compare like ↓)
Digital 0--to our $--to the end of our line
^--to the first non-whitespace character of the bank g_--with the last non-whitespace character of the bank
gg--to the first line of the file g--to the last line of the file (note uppercase)
Number ng--to nth row (colon: number n--can also specify n rows)
w--to the beginning of the next word e--to the end of the next word
w--to the next space before e--to the next space
%--matching parentheses move (including (), [], {}, need to move to a parenthesis first)
*/#--moves to the next/previous word that matches the word currently in the cursor
Insert : i--insert text before cursor a--insert text after cursor
o--inserts a new row after the current line o--inserts a new row before the current row (uppercase)
Delete : x--Delete the current cursor character
dd--Delete the current cursor row, delete the content in the Clipboard
[n]dd--deletes the n rows at the beginning of the line where the current cursor is located
copy : yy--Copy the current cursor in the row
[N]yy--n is a number that duplicates the n rows at the beginning of the current cursor
paste : p--paste the Clipboard to the cursor in the row
Search :/name<enter>--After looking for a string named "name" after the cursor, press N, jump between characters
undo : u--undo (note is lowercase) ctrl+r--fallback
override : r--replaces the character at the current cursor cw--the character at the end of a word from the position of the cursor
Other:gu--Word to uppercase gu--Word to lowercase
Cut = = delete + paste
Bottom-line mode :
: W Save (followed by filename, can save file as)
: Q Exit VI (System will prompt to save changes)
: Q. Forced exit (do not save for modification)
: Wq to exit after saving
: Set number Displays line numbers: Set Nonumber Cancel line number
:。 < system command > Execute a system command and display the results, press <enter> to return
:。 SH Switch to command line, press Ctrl+d to return vim
: Help <command> display VIM-related commands
: E <path/file> open a file: bn and: Switch between BP files (: N to next file)
better, faster , stronger.
Digital n<command>: repeated command command number n times, 3DD, 2p
. (decimal point): Repeats the last command
V: Visualize the operation (enter v before entering the command)
block Operation: Ctrl + V, Move cursor Selection object, I,<command>,esc effective
Auto Indent: Ctrl + V, move cursor selection line, =
Indent left and right: Ctrl + V, move cursor Select row,</>
Auto Tip: CTRL + N