Powerful Editor-Vim

Source: Internet
Author: User
Document directory
  • Search options
  • Cut/copy/paste

VIM: http://dsec.pku.edu.cn /~ Jinlong/VI/vi.html

 

Delete a row: dd

 

Delete the remaining word after a word/cursor: DW

 

Delete current character: x

 

Part of the row after the cursor: d $

 

 

Text Deletion

Dd deletes a row

D $ delete a line starting with the current character

 

NDD deletes n rows starting with the current row

DW deletes a word starting with the current character

Ndw deletes n characters starting with the current character

 

D and D $ are synonymous

 

D) Delete to the beginning of the next sentence

 

D} Delete it to the beginning of the next section

D. Press enter to delete two rows.

Ndw or ndw deletes n-1 characters starting at and following the cursor.
Delete D0 to the beginning of the row.
D $ Delete to the end of the row.
NDD deletes the current row and the next n-1 row.
Delete a character from X or X.
CTRL + u Delete the text entered in the input mode.
^ R restore u
J. Merge the next row to the end of the current row
V select a row
^ V press ^ V to select a rectangle.
Aw select word
IW internal words (no space)
As Select sentence
Is Select sentence (no space)
AP selection Section
IP selection section (no space)
D. Delete it to the end of the row.
X, Y Delete and copy contain highlight Area

DL deletes the current character (same as the X command)
D0 is deleted to the starting position of a row.
D ^ Delete the first character (excluding spaces or tab characters) to a row)
DW is deleted to the end of a word.
D3w is deleted to the end of the third word.
DB is deleted to the start position of a word.
DW is deleted to the end of a word with a space as the separator.
DB is deleted to the start position of a word with space as the separator.
D7b is deleted to the start position of the first seven words with spaces as separators.
D) Delete to the end of a statement
D4) to the end of the fourth statement.
D (delete to the start position of a statement)
D) delete it to the end of a paragraph.
D {Delete to the beginning of a paragraph
D7 {Delete the first 7th paragraph positions before the start position of the current paragraph
Dd deletes the current row
D/Text: Delete the position specified by "text" from the text,
Forward until the content of the next occurrence (but not including the word)
DFC deletes the position where the character "C" appears from the text and continues until the next occurrence of the character (including the character ).
DTC deletes the content from the current row until the next character "C" appears
D. Delete it to the end of a row.
D $ Delete to the end of a row
5dd Delete the contents of the five rows starting from the current row
Delete DL content until the last line on the screen
DH Delete until the first line of content on the screen
Delete content from the DG until the end of the work Cache
D1g Delete content that begins in the work Cache

 

 

Move the cursor in VI
K, H, L, left, right, J, down, ^, move to the first non-space character of the row W, move a word forward, use a symbol or punctuation as a word processing W, move a word forward, do not treat a symbol or punctuation as a word. B. Move a word backward. Use a symbol or punctuation as a word. B. Move a word backward. Do not use a symbol or punctuation as a word. (move the cursor to the beginning of the sentence) move the cursor to the end of the sentence {move the cursor to the beginning of the paragraph} move the cursor to the end of the paragraph h move the cursor to the top line of the screen M move the cursor to the middle line of the screen l move the cursor to the last line 0 to the beginning of the line to the end top G to the end of the page number + G jump to the specified row N + cursor move down n rows N-cursor move up n rows Ctrl + G query the current row information and the current file information FX jump to the right to the line x (X can be any character) FX jumps left to X (X can be any character). TX and FX are the same. The difference is that Tx and FX are the same before X, the difference is that C-B will 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 a row of NZ to roll row n to the top of the screen. If n is not specified, the current row is rolled to the top of the screen.
Access and exit VI commands
VI filename open or create a file, place the cursor at the beginning of the line vi + N filename open the file, and place the cursor at the beginning of line N vi + filename open the file, place the cursor in the first line of the last line vi +/pattern filename to open the file, place the cursor in the first pattern-matched string vi-r filename. A system crash occurred when VI was being edited with VI last time. Restore filenamevi filename... filename open multiple files, edit ZZ in sequence, exit VI, and save: Q! Exit VI, do not save: WQ exit VI and save
Repeated operation
. Repeat the previous operation
Auto-completion
C-N matches the next keyword C-P matches the previous keyword
Insert
O open a new line under the cursor and place the cursor at the beginning of the new line to enter the insert mode. O above the cursor. A enters the insert mode after the cursor. A is the same as above, before the cursor. R enters the replacement mode until you press escset XXX to set the xxx option.
Merge rows
J. Merge the following row to the end of the row.
Find and replace commands in VI
/Pattern Search for pattern from the beginning of the cursor to the end of the file? Pattern searches for the first part of the file starting from the cursor. patternn repeats the last SEARCH Command N in the same direction. n repeats the last search command in the opposite direction. % searches for matching parentheses: s/P1/P2/g replace all p1 in the current row with P2. If you want to ask the user for each replacement, use the GC option: N1, n2s/P1/P2/g replace all P1 from line N1 to line N2 with P2: G/P1/S // P2/g replace all p1 in the file with P2. * [] ^ % ~ $ It has a special meaning in VI. If you need to find it, you should add the Escape Character "\"
Some options for searching are highlighted.
: Set hlsearch setting highlight: Set nohlsearch closing highlight: nohlsearch closing the highlighted currently set
Incremental search
: Set incsearch: Set noincsearch to disable incremental search
Delete in VI
X Delete the character DW under the current cursor Delete the remaining part of the word after the cursor. D $ Delete the remaining parts of the row after the cursor. Dd deletes the current row. C functions are the same as D. The difference is that after the delete operation is completed, the insert modecc operation also deletes the current row and then the insert mode operation.
Change character
RX changes the character under the current cursor to X (X is any character )~ Change the case sensitivity of characters under the current cursor

 

Keyboard macro operations
Qcharacter starts recording macros, and character is any character from A to Z. Q terminates recording macros @ character calls the previously recorded macros
Restore misoperation
U undo the last executed command U undo the previous operation on this row Ctrl + R redo
Operate frame in VI
C-w c-n increase framec-w c-c decrease framec-w c-W switch framec-w c-r switch two frames
Block operations in VIM

Vim supports up to 26 clipboard

Use V, C-V, and V to select a block, copy it with Y, and paste it with P. YY copy the entire row nyy copy the content of N rows starting from the current row? Nyy saves the content of the current row and next n rows of the cursor to the register? , Where? Is a letter, and N is a number? Nyw saves the current row of the cursor and Its n words to the register? , Where? Is a letter, and N is a number? Nyl saves the current row of the cursor and Its n characters to the register? , Where? Is a letter, and N is a number? P will register? Paste the content in to the cursor position. If? Is the complete row copied with YY, Then paste it under the row where the cursor is located. Here? Can it be a letter or a number? P paste the content in register a before the cursor position. If? Is the complete row copied with YY, Then paste it on the row where the cursor is located. Here? It can be a letter, it can also be a number ay [motion] Ay $ copy the cursor position to the end of the row and save it in register a ayft copy the cursor position to the first letter T in the current row and save it in register

If all the preceding commands can remove a, Y and P work on the Untitled register (all the objects D, C, X, and Y are saved here ).

Cut/copy/paste

All deleted content is automatically saved and can be pasted with the p key.

VI option settings
All lists all options. Set the term. Terminal type. Ignorance. In the search, ignore the case-sensitive list. display the tab position (CTRL + I) and the end flag ($) number Display row number report display number modified by the line-oriented command terse display brief warning information warn when you go to another file if the current file is not saved no write information nomagic allows searching mode, use nowrapscan, which does not contain the special character "\" before to prohibit VI from searching to the two ends of the file, and start from the other end. mesg allows VI to display the information that other users write to their terminal using write.
Tips

Automatically format the code Gg = G

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.