Vim shortcut keys

Source: Internet
Author: User
Tags ord

First, move the cursor

H,j,k,l, down, left, right.
CTRL-E Mobile Page
Ctrl-f up a page
Ctrl-b down one page
Ctrl-u Half Page
ctrl-d down half a page
W Jump to the next word, split by punctuation or word
W jumps to the next word, long jump, as end-of-line is considered a word
e jumps to the end of the next word
E jump to the end of the next word, long jump
b jumps to the previous word
B jump to the last word, long jump
0 jumps to the beginning of the line, whether or not indented, jumps to the No. 0 character
^ Jumps to the first character of the beginning of a line
$ jump to end of line
GG jumps to the head of the text
G to the end of the text
5gg/5g To Line 5th
GD jumps to the declaration of the variable at which the cursor is currently located
FX finds the X character in the current line and jumps to
; Repeat the previous F command without repeating the input FX
* Find the word where the cursor is located and look down
# Find the word where the cursor is located, look up

Second, delete replication

DD deletes the cursor in the row
DW Delete one word (word)
D/DBy deletingExceptToYesLateXBy deletingExceptWhenAgoWordCharacterXBy deletingExceptAgoOneAWordCharacterYYComplexSystemOne line yw re system a word y /d Delete to end of line x delete current character x delete previous character yy copy one line yw copy a word y/y Copy to end of line
P Paste the contents of the clipboard below the current line
P Paste the Clipboard contents to the top of the current line

Three, insert mode

I enter insert mode from the current cursor
I go into insert mode and place the cursor at the beginning of the line
A append mode, with the cursor positioned after the current cursor
A Append mode with cursor at end of line
o Add a new line below the current line and enter insert mode
O add a new line above the current line and enter insert mode
ESC exits insert mode

Iv. editing

J connect the next line and the current row as a row
CC Deletes the current line and enters edit mode
CW Deletes the current word and enters edit mode
C $ erases content from the current position to the end of the line and enters edit mode
s delete the current character and enter edit mode
S Delete the line of the cursor and enter edit mode
XP swaps the current character and the next character
U undo
Ctrl+r Redo
~ Toggle case, current character
>> move the current line one unit to the right
<< moves the current line one unit to the left (one tab character)
= = automatically indent as you go forward

V. Find and replace

/pattern Backward Search string pattern
? pattern searches forward string pattern
"\c" ignores case
"\c" Case sensitive

N Next match (if yes/search, then down next,? Search is up next)
N previous match (IBID.)
:%s/old/new/g Search entire file, replace all old with new
:%S/OLD/NEW/GC searches the entire file, replaces all old with new, and each time you confirm whether to replace

Vi. Exit Editor

: W writes buffer to file, saving modify
: Wq Save changes and exit
: x Save changes and exit
: Q Exits, if the buffer has been modified, it will prompt
: q! Force quit, discard modifications

Seven, multi-file editing

Vim File1. Open multiple files at the same time
: args Displays the currently edited file
: Next switches to the next file
:p Rev Switch to previous file
: next! Do not save the current edit file and switch to the next file
:p rev! Do not save the current edit file and switch to the previous file
: Wnext Save the current edit file and switch to the next file
: Wprev Save the current edit file and switch to the previous file
: First Location header file
: Last Location Tail file
ctrl+^ quickly switch between the last two files opened
: SPLIT[SP] Split the current file horizontally
: Split file splits the current window horizontally, file
: vsplit[vsp] File to split the current window vertically, file
: New file with split file
: Close closes the current window
: only displays the current window, closes all other windows
: All open All windows
: Vertical all open all windows, open vertically
: Qall is performed on all windows: Q operation
: qall! Perform for all windows: q! operation
: Wall is performed on all windows: W operation
: Wqall for all windows: Wq operation
Ctrl-w h jump to the left window
Ctrl-w J jump to the window below
Ctrl-w K jump to the upper window
Ctrl-w L jump to the right window
Ctrl-w T jumps to the topmost window
Ctrl-w b Jump to the bottom of the window

Eight, multi-label editing

: Tabedit file opens files in new tab
: Tab split file opens files in new tab
: TABP Switch to previous tab
: TABN switch to the next tab
: TABC Close Current tab
: Tabo Close other tabs
GT to next tab
GT to Previous Tab
0GT jumps to the first tab
5GT Jump to Fifth tab

Nine, execute shell command

1, enter ": SH" in the command mode, can run equivalent in character mode, to the end of the input to return to the Vim editor with Exit,ctrl+d back to the VIM editor
2, can "!command", after the end of the run automatically back to the VIM editor
3. Back to Shell with "Ctrl + Z", return to edit with FG
4:!make, run the make command directly in the current directory

Ten, Vim startup item

-O[N] Open multiple files in a horizontal split-screen way
-O[N] Open multiple files in vertical split-screen mode

Xi. Automatic typesetting

After pasting some code, VIM becomes messy and can be done just by executing gg=g.

12. How to compile the program in VIM

You can complete make in vim, and you can also display the results of the compilation in Vim, first execute: Copen command, open the Output window of the result, and then execute: Make
The compiled result is displayed in the Copen open window, and with the mouse double-click the error message, you will jump to the line where the error occurred.

13. Buffer operation

1. Buffer state
-(inactive buffer zone)
A (currently activated buffer)
H (hidden buffer zone)
% (current buffer area)
# (Swap buffer)
= (read-only buffer)
+ (buffer area that has changed)

14. VIM Operation Catalogue

1. Open Directory
Vim.
Vim a-path/

2. The following actions take effect when operating the directory
P,p,t,u,u,x,v,o,r,s

C makes the currently open directory the current directory
D Create a directory
% Create File
D Delete files/directories
-Go to Upper directory
GB go to previous bookmarked directory
I change the way directory files are listed
^l Refresh the currently open Directory

MF-Tag File
Mu-unmark all marked files
Mz-compress/decompress marked files
GH Show/Do not show hidden files (dot-files)
^h Edit Hidden file list
A conversion display mode, All-hide-unhide
QF Diplay infomation about file
QB list the bookmarked directories and directory traversal history
GI Display information on file

Mb
Mc
MD-use diff mode for tagged files (mf tag files)
Me-Edit tagged file, show only one, rest put in buffer
Mh
Mm-move marked files to marked-file target directory
Mc-copy
Mp
Mr
Mt

Vim Copy, move file
1, MT-moved to the directory
2, MF-mark the file to be moved
3, MC-Move/Copy

R Moving files

Open the Directory of the currently edited file
: Explore
: Hexplore
: Nexplore
:P Explore
: Sexplore
: Texplore
: Vexplore

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.