Common VI commands and explanations

【Working mode of VI 1.
Command mode 2.
Insert mode
3. Last line mode Insert s at the end of the line to cut a character after the cursor, and change to insert mode S to cut the line where the cursor is located, and change to insert mode Start a new line above and change to insert mode (cut, copy, paste and undo text) x cut the next character X cut the previous character nx cut n characters after the cursor dd cut a line (in delete 'd') D cut to end of line ndd/nD cut n lines/cut to end of n lines J delete newline, make next line and come up



















n lines after nJ join
Y/yy copy whole line
yw copy a word
nyy copy n lines starting from the current line
p paste on the next line ('p' in paste)
p paste on the previous line
u undo the last action (in undo 'u')
U undo all modifications of the current line
ctrl+r undo
(cursor movement)
k/j/h/l or arrow keys up, down right
/keywords to find keywords, press n to jump To the next, N previous
^/0 move to the beginning of the line
$ move to the end of the line
w move one word to the right, the cursor is at the beginning of the next word ('w' in forword)
nw move n words to the right, where the cursor is Move the prefix
b of the nth word to the left by one word, the cursor is at the prefix of the next word ('b' in back)
nb move to the left by n words, the cursor is at the prefix of the nth word
( move to this The beginning of the sentence, if it is already at the beginning of the sentence, move to the beginning of the previous sentence
) Move to the beginning of the next sentence
{ move to the beginning of this paragraph, if already at the beginning of the paragraph, move to the beginning of the previous paragraph
} Move to the beginning of the next paragraph
+ move to the beginning of the next line
- move to The beginning of the previous line
Put the cursor at "{", and then enter v% to select the content in the curly brackets.
If the cursor is placed on the first s, and want to delete until "(", then enter dt (just Okay, the function of t( is to jump to the corresponding bracket before the next "("
. When programming, nG is often used to jump to the beginning of the nth line. At this time, press `` to return to the original line position, and press ''Can return to the beginning of the original line gg/1G Move to the beginning of the first line of the file G Move to the beginning of the last line of the file <Ctrl>+g Report the position of the cursor, the position information is displayed in the last line of the VI ctrl +u/d scroll up/down half screen ctrl+y/e scroll up/down one line ctrl+b/f scroll up/down one screen This is more practical, remember that zz scrolls the current line in the middle of the screen, which is convenient for viewing the context zt








Scroll the current line to the top of the screen for easy viewing below
zb Scroll the current line to the bottom of the screen for easy viewing above
ps: When encountering '.' or '?' or '!', VI considers it to be the end of a sentence, and VI ends with a blank line as the start or end of the segment
last line mode
n1,n2ycopy n1 to n2 line
n1,n2d delete n1 to n2 line
n1,n2mn3          n1 to n2 cut to n3 after
n1,n2con3          n1 to n2 copy and paste to n3 after
set number/nu displays the line number
set nonu          hides the line number
[simple configuration of common VIs]
set number displays the line number
set cursorline highlights the current line
set tabstop=4 tab length is set to 4
set ruler          displays the status line of the cursor position in the lower right corner
set autoindent is automatically aligned, use the
syntax on of the previous line to          open the syntax height display
set smartindent smart alignment
set shiftwidth=4          Set the indent length when aligning
set tabstop=4 Set the TAB indent length
set mouse=a Allow the cursor to be moved with the mouse
map<Fn> : Command in line mode <CR>
map<Fn> Command in view mode

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325622878&siteId=291194637