Vim shortcut keys

Source: Internet
Author: User

Original address: Http://blog.csdn.net/AbnerChai/archive/2005/09/03/470824.aspx

Move cursor
On: K NK: Move up n rows 9999k or GG can move to the first line G move to the last row
Under: J NJ: Move Down n rows
Left: H NH: Move n columns to the left
Right: L nl: Move n columns to the right

W: Cursor moves forward with a word NW: the cursor moves forward n the word cursor to the first letter of a word
B: Contrary to W
E: Cursor moves forward with a word ne: the cursor moves forward n the word cursor to the last letter of the word
GE: Contrary to E

$: Move cursor to end of line n$: Move to line end of Nth row
0 (Num): Moves the cursor to the beginning of the line
^: Move the cursor to the first non-empty character at the beginning of the line

F<A>: Moves the cursor to the character a of the current line,nf<a> moves the cursor over the nth a character of the current line
F: On the contrary

%: Move to the parentheses that match the system up (),{},[],<> and so on.

NG: Move to Nth line G: to the last row

Ctrl+g get the current cursor position in the file

Page forward: ctrl+f
Move Down half screen: ctrl+g
Page Backward: ctrl+b

Save:
: q! : Do not save to exit
: e! : Discard modify file contents, reload the file edit
: Wq: Save and exit

DW: Delete A word, you need to move the cursor to the first letter of the word, press DW, if the cursor is anywhere in the word, use the Daw
DNW: delete N words
Dne: can also, just delete to the end of the word
DNL: Delete n letters to the right
DNH: Delete n letters to the Left
DNJ: delete n rows down
DNK: delete n rows up
d$: Delete the letter of the current cursor to the end of the line
DD: Delete a row
Cnw[word]: change n word to Word
cc: Change whole line
C $: Change to end of line

J: Remove line breaks, move the cursor to a row, press Shift+j to delete line breaks at the end of the row, and next line up.
U: Undo the previous operation
Shif+u (U): revokes all operations on the row.

: Set Showmode: Setting display mode of operation

O: Another line below the current line
O (shift+o): Another line above the current line

NK or NJ: The cursor moves up or down n lines, N is a number
an! "ESC": Add n exclamation marks (!) after line
NX: Perform N-times x (delete) operations

ZZ: Save the current document and exit Vim

: Help: View the assistance document, and in this, press CTRL +] to enter the hyperlink and press Ctrl+o to return.
: Help subject: Look at a topic for assistance, ZZ exit Help

: Set Number/set nonumber: Display/Do not display line numbers
: Set Ruler/set Noruler: Show/not show ruler

/pattern searching for a character pattern in the positive direction
? pattern Reverse direction search for a character pattern
Then press N to continue looking down.

Place the cursor over a word and press the X key to find the word.
Find the whole word:/\<word\>

: Set Hlsearch highlight the found word
: Set Nohlsearch Turn off Change function

M[A-Z]: Mark in the text, the mark number can be a A-Z 26 letters, with ' A can be moved to mark a

R: Replace the current character
NR character: Replaces the current n characters

Find Replacements:
Way1:
/Word: Find a Word
CW "Newword": Replace with new word
N: Continue to find
.: Perform a replacement

Way2:
: s/string1/string2/g: Replace string1 with string2,g in a row to indicate that a C is required to confirm
: num1,num2 s/string1/string2/g: Replace string1 with string2 in the middle of line NUM1 to num2
: 1,$ s/string1/string2/g: Replace string1 with string2 in full text


V: Enter visual mode
"ESC" exits
V:shift+v visual mode for entering rows
Ctrl + V: Enter as block operation mode with O and O to change the size of the selected edges.

Paste: P, which is pasted with x or D deleted text
Copy:
YNW: copy n words
YY: Copy one line
YNL: Copy n characters
y$: Copy the current cursor to the end of the line
Nyy: Copy n rows
Finished with P paste

: Split: Split a window
: Split file.c: file.c separate window for another file
: Nsplit file.c: Separate window for another file file.c and specify its number of rows
Ctrl+w switch in the window
: Close: Closes the current window

Insert the same content as include< on all rows, as follows:
Move the cursor to the location where you started the insertion, press CTRL + V to enter visual mode, and then select a good module
Press I (shift+i), insert the text you want to insert, and press [ESC] to finish.

: Read FILE.C Inserts the contents of the file file.c below the current cursor
: 0read file.c Inserts the contents of the file file.c at the beginning of the current file (line No. 0)
: Nread file.c Inserts the contents of the file file.c after the nth line of the current file
: Read!cmd: The output of the external command cmd is inserted below the current cursor

: N1,n2 Write Temp.c writes N1 in this file to N2 line to temp.c this file

Ctrl+l Refresh Screen
SHIFT + < move left one line
SHIFT + > Move right one line

U:undo
Ctrl+r:re-do
J: Merge one row
Ctrl+p Auto-complete function
Ctrl+g view current file full path

Q[a-z] Start recording but before the action is a macro, the name can be "A-Z", and then use Q to stop recording the macro.
Use Reg to display all currently defined macros, using @[a-z] to execute the macro [a-z] at the current cursor.

Copyright by Abnerchai, 2005.

Form:http://blog.csdn.net/abnerchai/archive/2005/09/03/470824.aspx

Move cursor
On: K NK: Move up n rows 9999k or GG can move to the first line G move to the last row
Under: J NJ: Move Down n rows
Left: H NH: Move n columns to the left
Right: L nl: Move n columns to the right

W: Cursor moves forward with a word NW: the cursor moves forward n the word cursor to the first letter of a word
B: Contrary to W
E: Cursor moves forward with a word ne: the cursor moves forward n the word cursor to the last letter of the word
GE: Contrary to E

$: Move cursor to end of line n$: Move to line end of Nth row
0 (Num): Moves the cursor to the beginning of the line
^: Move the cursor to the first non-empty character at the beginning of the line

F<A>: Moves the cursor to the character a of the current line,nf<a> moves the cursor over the nth a character of the current line
F: On the contrary

%: Move to the parentheses that match the system up (),{},[],<> and so on.

NG: Move to Nth line G: to the last row

Ctrl+g get the current cursor position in the file

Page forward: ctrl+f
Move Down half screen: ctrl+g
Page Backward: ctrl+b

Save:
: q! : Do not save to exit
: e! : Discard modify file contents, reload the file edit
: Wq: Save and exit

DW: Delete A word, you need to move the cursor to the first letter of the word, press DW, if the cursor is anywhere in the word, use the Daw
DNW: delete N words
Dne: can also, just delete to the end of the word
DNL: Delete n letters to the right
DNH: Delete n letters to the Left
DNJ: delete n rows down
DNK: delete n rows up
d$: Delete the letter of the current cursor to the end of the line
DD: Delete a row
Cnw[word]: change n word to Word
cc: Change whole line
C $: Change to end of line

J: Remove line breaks, move the cursor to a row, press Shift+j to delete line breaks at the end of the row, and next line up.
U: Undo the previous operation
Shif+u (U): revokes all operations on the row.

: Set Showmode: Setting display mode of operation

O: Another line below the current line
O (shift+o): Another line above the current line

NK or NJ: The cursor moves up or down n lines, N is a number
an! "ESC": Add n exclamation marks (!) after line
NX: Perform N-times x (delete) operations

ZZ: Save the current document and exit Vim

: Help: View the assistance document, and in this, press CTRL +] to enter the hyperlink and press Ctrl+o to return.
: Help subject: Look at a topic for assistance, ZZ exit Help

: Set Number/set nonumber: Display/Do not display line numbers
: Set Ruler/set Noruler: Show/not show ruler

/pattern searching for a character pattern in the positive direction
? pattern Reverse direction search for a character pattern
Then press N to continue looking down.

Place the cursor over a word and press the X key to find the word.
Find the whole word:/\<word\>

: Set Hlsearch highlight the found word
: Set Nohlsearch Turn off Change function

M[A-Z]: Mark in the text, the mark number can be a A-Z 26 letters, with ' A can be moved to mark a

R: Replace the current character
NR character: Replaces the current n characters

Find Replacements:
Way1:
/Word: Find a Word
CW "Newword": Replace with new word
N: Continue to find
.: Perform a replacement

Way2:
: s/string1/string2/g: Replace string1 with string2,g in a row to indicate that a C is required to confirm
: num1,num2 s/string1/string2/g: Replace string1 with string2 in the middle of line NUM1 to num2
: 1,$ s/string1/string2/g: Replace string1 with string2 in full text


V: Enter visual mode
"ESC" exits
V:shift+v visual mode for entering rows
Ctrl + V: Enter as block operation mode with O and O to change the size of the selected edges.

Paste: P, which is pasted with x or D deleted text
Copy:
YNW: copy n words
YY: Copy one line
YNL: Copy n characters
y$: Copy the current cursor to the end of the line
Nyy: Copy n rows
Finished with P paste

: Split: Split a window
: Split file.c: file.c separate window for another file
: Nsplit file.c: Separate window for another file file.c and specify its number of rows
Ctrl+w switch in the window
: Close: Closes the current window

Insert the same content as include< on all rows, as follows:
Move the cursor to the location where you started the insertion, press CTRL + V to enter visual mode, and then select a good module
Press I (shift+i), insert the text you want to insert, and press [ESC] to finish.

: Read FILE.C Inserts the contents of the file file.c below the current cursor
: 0read file.c Inserts the contents of the file file.c at the beginning of the current file (line No. 0)
: Nread file.c Inserts the contents of the file file.c after the nth line of the current file
: Read!cmd: The output of the external command cmd is inserted below the current cursor

: N1,n2 Write Temp.c writes N1 in this file to N2 line to temp.c this file

Ctrl+l Refresh Screen
SHIFT + < move left one line
SHIFT + > Move right one line

U:undo
Ctrl+r:re-do
J: Merge one row
Ctrl+p Auto-complete function
Ctrl+g view current file full path

Q[a-z] Start recording but before the action is a macro, the name can be "A-Z", and then use Q to stop recording the macro.
Use Reg to display all currently defined macros, using @[a-z] to execute the macro [a-z] at the current cursor.

Vim shortcut keys

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.