x Delete the characters under the current cursor
DW Deletes the remainder of the word after the cursor.
d$ the remaining portion of the line after the cursor is deleted.
DD deletes the current line.
the C function is the same as D, except that when the delete operation is complete, insert MODE
CC also deletes the current line and then enters insert MODE
Delete the first character of each line :%s/^.//g
I believe VI is what you do not need me to introduce more, this tool since the birth of Unix has been the standard editor under the terminal. Almost every Unix or Unix-like operating system provides VI. Vim is the abbreviation of VI improved, which has a great expansion compared with VI. The VI improved 6.3 is used here.
Move cursor in VI
K Upper H L right J down ^ move to the first non-space character of the line prompt W move forward one word, the symbol or punctuation as the word processing W move forward a word, Do not place a symbol or punctuation as a word processing B move backward through a word, place a symbol or punctuation as a word processing B to move backward through a word, without the sign or punctuation as the word processing (the cursor moves to the beginning of the sentence) the cursor moves to the end of the sentence { Move the cursor to the beginning of the paragraph} The cursor moves to the end of the paragraph H cursor moves to the top line of the screen m cursor moves to the Middle Line of the screen L cursor moves to the last line of the screen 0 to beginning $ to line end GG to top g To the end of the page +g jumps to the specified line n+ the cursor moves n rows, the n -cursor-up line, ctrl+g queries the current line information and the current file information FX jumps right to the bank character X (x can be any character) FX Jump left to the bank character X (x can be any character) TX and FX The same, the difference is to jump to the character x before the TX and FX The same, the difference is to jump to the character x after c-b scroll up one screen c-f scroll down one screen c-u Scroll up half screen c-d scroll down half screen c-y scroll up one line c-e scroll down one line NZ
Enter and Exit VI command
VI filename Opens or creates a new file and places the cursor at the beginning of the first line VI +n filename to open the file and places the cursor at the beginning of nth line VI + filename to open the file and place the cursor at the end of the line VI +/pattern FileName Opens the file and places the cursor at the first string that matches the pattern vi-r filename crashes when you last edited with VI, recovers FILENAMEVI filename ... filename Open multiple files, then edit ZZ to exit VI and Save: q! Exit VI, do not save: Wq exit VI and save
Repeat operation
. Repeat Last Action
Auto-Completing
C-n match next keyword c-p match previous keyword
Insert
o open a new line below the cursor and place the cursor at the beginning of the new line, into insert mode. O Ibid., above the cursor. A enters insert mode after the cursor. A Ibid., before the cursor. R Enter replacement mode until you press Escset XXX to set the XXX option.
Row merge
J Merge The following line behind the bank
VI Find and Replace commands
/pattern from the beginning of the cursor to the end of the file search Pattern?pattern from the beginning of the cursor to the top of the file Patternn in the same direction repeat the last search command n in the opposite direction repeat the last search command% Find pairs of parentheses: s/p1/p2/g all the P1 in the current row are replaced with P2, and the GC option should be used if each substitution asks the user: N1,n2s/p1/p2/g all N1 in the N2 to P1 row are replaced with P2: g/p1/s//p2/g Replace all P1 in the file with P2. The *[]^%~$ has a special meaning in VI, and the escape character "\" should be added if you need to find it.
Some options for finding
Set highlighting
: Set Hlsearch Set highlight: Set Nohlsearch off highlight: Nohlsearch Close the highlight that is currently set
Incremental Lookup
: Set Incsearch Set incremental lookup: Set Noincsearch close Incremental Lookup
Delete in VI
x Delete the character under the current cursor DW deletes the remainder of the word after the cursor. d$ the remaining portion of the line after the cursor is deleted. DD deletes the current line. the C function is the same as D, except that when the delete operation is completed, the insert MODECC is deleted and the current line is removed, and then the insert MODE is entered
Change character
Rx Changes the character under the current cursor to X (any character x) ~
Keyboard macro Actions
Qcharacter start recording macro, character any character from A to Z Q stop recording macro @character call previously recorded macro
Recovering from a false operation
U undo the last executed command u fix the previous operation on the line ctrl+r Redo
Operate the frame in VI
C-w c-n Increase framec-w c-c decrease framec-w c-w switch framec-w c-r swap two frame
Block operations in VIM
Vim supports up to 26 clipboard
Select a block first with v,c-v,v, and then copy with Y, and then paste with P. yy Copy the current entire row nyy copy the N-line content at the beginning of the current line ? Nyy saves the contents of the current line and its next n rows to the register? in Which? is one letter and N is a number ? NYW Saves the current line of the cursor and its next n words to a register, where? is one letter and N is a number ? nyl Saves the current line of the cursor and its next n characters to the Register?, where? is a letter, n is a number ? P will register? Paste the contents of the text into the cursor position. If it is a full line copied with yy, paste it under the line where the cursor is located. Here? Can it be a letter, or can it be a number ? P Pastes the contents of register a before the cursor position. If it is a full line copied with yy, paste it on top of the line where the cursor is located. Here? can be a letter or a number ay[motion] ay$ Copy the cursor position to the end of the line and save in register a ayft copy the cursor position to the current line the first letter T and save in Register a
All of the above instructions can be removed from a work, then y,p works on the unnamed register (all D,c,x,y objects are saved here).
Cut/Copy/paste
All deleted contents are saved automatically and can be pasted with P key.
Option settings for VI
all lists all option settings for the term set Terminal type ignorance in search ignore case list Display tab stop (CTRL+I) and Line end flag ($) number display line numbers report Displays the number modified by the line-oriented command terse displays a short warning message warn If the current file is not saved when you go to another file Nomagic allow in search mode, use the front without "\" The special character Nowrapscan prohibit VI when the search reaches the end of the file, and then starts at the other end MESG
Tips
Automatic formatting of code GG=G
VIm VI Usage Summary