Vim shortcut keys and vim common shortcut keys

Source: Internet
Author: User
Tags add numbers

Vim shortcut keys and vim common shortcut keys

# Vim filename

: Scriptname// View scripts loaded by vim

: Set nu// Set the row number

: Set tabstop = 4// Set a tab to 4 spaces

: Set ai// Set Automatic indent

Space key// Move one cell to the right

X// Delete the subsequent characters (in command mode)

X// Delete the first character. Delete the three characters to 3x.

Dd// Delete a row

D// Delete to the end of the row

Caw// Rewrite the word. c is equivalent to changing d to the editing mode.

J// Delete the linefeed so that the next line is up and the nJ is connected to the next n lines

U// Cancel the last operation

U// Undo all modifications to the current row

Ctrl + r// Undo

I// Insert before the cursor

I// Insert at the beginning of the row

A// Insert at the cursor

A// Insert at the end of the row

O// Start another row under the current row and change to the insert mode

O// Start another row on the current row and change to the insert mode.

Ctrl + o// Temporarily change to command mode (effective once)

: E!// Discard the change, which is equivalent to re-opening

: Help// Help. Exit the Help window with ZZ.

: 10, 20y// Copy 10 to 20 rows or 10yy/yy10

: 10, 20d// Delete

: 10, 20 m 30// 10 to 20 rows of content, cut to 30 rows

: 10, 20 co 30// 10 to 20 rows after 30 rows

Place the cursor{And enter v % to select the content in braces.

If the cursor is placed on the first s and you want to delete it until (, enterDt (That's it. t (the role is to jump to the next "("

Ctrl + nAuto-completionCtrl + pThe same is true.

: AB hw hello worldReplace a long string with an abbreviation, and use hw to replace hello world.

#To the previous word that is the same as the current word

*To the next word that is the same as the current word

B, 3b, w, 3 w:Move a few words forward and backward, and the punctuation is also a word. The corresponding uppercase state is without punctuation, that is, only the space and linefeed are used as word separators.

$:Move to end of line3 $:Move to the end of the three rows

^:Move to the beginning of a row,0Yes

+:Move to the beginning of the next row

-:Move to the beginning of the previous row

F:SEARCH Command. Search backward (used to locate) in lower case, as shown in figureFx: Go to the next x.Fx: Located on the previous x, available when repeated; or, but, indicates the opposite direction

%:Jump to the corresponding brackets, often used for programming

33G:To jump to 33 rows, press''Returns to the original row.

Gg:File HeaderG:End of File

30%: Jump to Part 1 of the file

"H"Home,"M"Is Middle,"L"It is Last. The upper and lower positions of the current screen, which are case sensitive.

Ctrl + G:Show current location

Set number:Set the display row number,Set nonumber:Disable display

: Set rulerThe row number is displayed in the lower-right corner of the window.

Ctrl + u \ dScroll up/down half screen

Ctrl + e \ yScroll up/down a row

Ctrl + B \ fIt is more practical to scroll up or down a screen. Remember.

Zz:Scroll the current row in the middle of the screen to view the contextZtPIN to top,ZbTail setting

/StringSearch for string, press enter, andNThe key can jump to the next one,NThe previous one, and/PressUp/down keysYou can find the previously searched records.:There are also records

? /StringSame as above. Search up by default

: Set ignorecaseCase-insensitive

: Set noignorecaseCase Sensitive

*:Find the word with the next cursor#Is to find the previous

: Set hlsearchHighlight search results

: Set nohlsearchDeselect highlight

: NohlsearchRemove the currently displayed high end (one time)

 ''Last line docked by the cursor

%Matched to the corresponding brackets

>Move the row to the right.<Move a distance from the row to the left3 <Move the following three rows (including rows) to the left: 20, 30>Move rows 20 to 30 to the right for a distance.

: % S/str1/str2/gReplace str1 with str2 for each row

: 10, 20 s/str1/str2/gReplace str1 from line 10 to line 20 with str2

: 10, $ s/str1/str2/gReplace str1 from line 10 to the last line with str2

: S/str1/str2/gReplace str1 of the current row with str2

.Execute commands repeatedly

: 10, $ w test2.cppExtract the content from the row 10 to the last row and save it to test2.cpp.

: R class/User. hppRead the content in the file and insert it to the end of the current row.

Dw:Deleting a word (the part after the cursor) is not as practical as daw.D4w: Delete four wordsD $: Delete the current cursor to the end of the rowD ^: It is the same to delete the current cursor to the beginning of the line d and change it to c, but the operation will change to insert mode after the operation is complete.Dnw: Delete N wordsDnj:Delete n rows downDnk:Delete n rows up

X:Delete the character on the left, which is equivalent<-Key,XDelete current characterD: equivalentD $C: equivalentC $S:Equivalent to c1S:Equivalent to cc

R:Replaces the current character, but does not enter insert mode3r:Replace the last three charactersR:Replacement Mode

.:Repeat the previous operation

V:Enter Visual modeV:Enter the visible line mode, suchVjjdDelete 3 rowsCtrl + v:Visual Block Mode

P:Paste to front of the cursorP:Paste to the cursor3 P:Paste 3 times"2 pPaste the last second deleted content

Yy:Copy a rowYaw:Copy a word and place the cursor at any position of the wordYnw:Copy N wordsYnj:Copy n rows downYnk:Copy n rows up

 

Automatic indent:

: Set cindent(All sets can be abbreviated as se. Although only one character is saved, the Translator's note) Note that cindent controls the indentation by using the value of the shiftwidth option, instead of using the tabstop value, the shiftwidth default value is 8 (that is, an indent is 8 spaces, the Translator's note). To change the default setting, you can use": Set shiftwidth = x"Command. x indicates the number of spaces that you want to indent.

{=To the previous empty line
} =To the next empty line

 

Plug-in Commands

: E!Returns the last saved status.

Ctrl + z:Pause vi, return to the Unix prompt, and then enterFgYou can return to vi.

 ^Return to the beginning of the line, with the cursor at the beginning of the line;0Return to the beginning of the line. The cursor is placed before the first letter of the line.$Return to the end of the row. The cursor is at the end of the row.

Nb:Move n words forward,Nw:Move n words backward. The cursor is at the first letter of the word. The operation in nw is very slow, somehow. It is separated by spaces, punctuation marks, and words. (Several consecutive punctuations are regarded as one word.) You can also use nB and nW, but only use them here.SpaceAs a separator.

Change the location of two adjacent letters:X, p

S:Delete a character and enter the editing mode.S:Deletes a whole row and enters the editing mode, which is equivalentCc.Ns:Delete the next n characters and enter the editing mode.

~ :Change the case sensitivity of the letter and move the cursor to the next character.N ~ :Change the case sensitivity of the next n letters.

Dw:Delete part after a wordDb:Delete the first part of a word. If you want to delete the entire word (the cursor is in the middle of the word), you canDbw \ wdb

De:SimilarDw, Delete the part after the word (only to the end of the word, dw will delete the space behind the word)DE:The deleted range is the end of a word, including the number.

E:It is equivalent to w. Move one word backward. The difference is that,WMove to the first character of a word,EMove to the last character of a word. Therefore, ea can append content to this word.

D: d $In short, the same,C: c $.

U:Will restore the original line of appearance, that is, the original look.

Y:EquivalentYyDifferent from the operation methods of D and C.

.:Repeat the previous command.

In addition to O/o, the INSERT command (A, a, I, I) accepts numeric parameters, such as 5 Ihello, and then press the ESE key. Enter five connected hello records at the beginning of the row.

Nr:Replace the next n characters.

NJ:Merge the following n rows (from this row ).

Ynl:Copy n characters to the backend.

E/E:To the end of a word.

 

Scroll the whole screen:

^ F:Forward (down) a whole screen

^ B:One screen (up)

^ D:Front (bottom) half screen

^ U:Half screen (up)

Z, Enter:Move the row where the cursor is located to the top of the screen (equivalentZz)

Z .:Move the row where the cursor is located to the center of the screen

Z -:Move the row where the cursor is located to the end of the screen

Nz, Enter:Move row n to the top of the screen. Similarly, you can add numbers before z. and z.

 

Move on screen:

H, M, LMove to the top, middle, and end of the screen.

NH, nLMove n rows away from the top and top of the screen.

 

Enter:The first character in the next line.

+:The first character in the next line.

-:The first character in the previous line.

N |:Move to column n of the current row

E:Move to the end of a word

E:Move to the end of a word (ignore punctuation)

() {} [[] Is not very useful for programming and can be ignored.

D/it:Delete the location before it (do not delete it ).D? It:Delete it ).

 

Fx:In this row, search for x to the right, and place the cursor on x.Fx:Search left.;Repeat the previous search command in the same direction. ,Repeat the previous search command in the opposite direction.

Tx:The same as fx, but the cursor is placed before x. Tx is similar.

Dfi:Delete the first I position (including I) to the right)MHD:Same as dfi, but does not include I

Ctrl + GView current row Information

NGAfter the jump, you can use''Back to the last position,''The function is the same, but it only returns to the beginning of the row where the previous position is located, rather than the specified position.

 

Delete a row that contains a keyword string:: G/keyword/d

Delete empty rows:: % S/^ \ n $/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.