vim related commands in Linux

There are three working modes in vim, which are command mode, input mode, and last line mode

Just entering the editor is in the command mode, switch to the input mode to enter: i, I, o, O, a, C

a: Insert after the cursor
A: Insert at the end of the line where the cursor is located
i: Insert at the cursor
I: Insert at the beginning of the line where the cursor is located
o: Jump to the line below the cursor to insert a line
O: Jump to the line above the cursor to insert a line
C: Clear Everything after the cursor position enters input mode

Switch from command mode to last line mode and press shift+:

Press esc to return to command mode
Input mode and last line mode cannot be switched directly

Shortcut operations in the command line state:
dd: cut the line where the cursor is located (add a number before it to indicate how many lines to cut***use with caution)
yy: copy the line where the cursor is located (add a number before it to indicate how many lines to copy)
p: Paste the copied line
gg: Switch the cursor to the first line
G: Switch the cursor to the last line Line
number+G: Switch the cursor to the specified line
u Restore the result before the last command.
Ctrl+r can restore the content before undo, press multiple times to restore multiple times.

Window adjustment:
Ctrl+f scrolls down one page.
Ctrl+b window scrolls up one page.
Ctrl+d Scroll down half a page in the window.
Ctrl+u scrolls up half a page in the window.
Ctrl+e window scrolls down one line.
Ctrl+y window scrolls up one line.

Shortcut operations in the command line state:
Ctrl+w: delete a string, split by punctuation or word
Ctrl+u: delete to the beginning of the line
Ctrl+Shift+c: copy the selected content
Ctrl+Shift+v: paste the selected content

TIPS: After pasting some code, vim becomes messy, just execute gg=G to get it done

Guess you like

Origin blog.csdn.net/weixin_45313494/article/details/125954913