Vim command set

Source: Internet
Author: User
Tags file info
Command Action Notes
Vim file + 54 Open File and go to line 54 Any: command can be run using + on command line
Vim-O file1 file2 Open file1 and file2 side by side  
Insert Enter insert mode So you can start typing. Alternatively one can useIOrA.
ESC Leave insert mode So you can issue commands. note in VIM the cursor keys & {home, end, page {Up, down} and delete and backspace work as expected in any mode, so you don't need to go back to command mode nearly as much as the origonal VI. note even Ctrl + {left, right} jumps words like most other editors. note also Ctrl + [andCTRL + cAre equivalent to ESC and may be easier to type. Also Ctrl + O in insert mode will switch to normal mode for one command only and automatically switch back.
: Command Runs named COMMAND  
: Help word Shows help on word Typing Ctrl + d after word shows all entries containing word
: Echo & Word Shows value of Word  
Windows
: E Set buffer for current window You can optionally specify a new file or existing buffer number (#3 for e.g.). Note if you specify a directory a file browser is started. E. g.: E.Will start the browser in the current directory (which can be changed with the: CD command ).
: SP New window above Ditto
: New window to left Ditto
: Q Close current window  
: QA Close all windows Add trailing! To force
CTRL + W {left, right, up, down} Move to window  
CTRL + W Ctrl + W Toggle window focus  
CTRL + W = Autosize windows To new terminal size for e.g.
: Ba New window for all Buffers ": Vert ba" tiles windows vertically
Buffers
: Ls List Buffers  
GF Open File under cursor  
: BD Delete Buffer And any associated windows
: W Save File Note: up [date] only writes file if changes made, but it's more awkward to type
: SavFilename Save file as filename Note: W filename doesn't switch to new file. Subsequent edits/saves happen to existing file
Undo/Redo
U Undo  
CTRL + R Redo  
. Repeat  
Navigation
Gg Goto start of File  
G Goto end of File  
: 54 Goto line 54  
80 | Goto column 80  
CTRL + G Show file info Including your position in the file
GA Show character info G8 shows utf8 Encoding
CTRL + E Scroll up CTRL + x needed first for insert mode
CTRL + Y Scroll down CTRL + x needed first for insert mode
ZT Scroll current line to top of window  
W Goto next word Note Ctrl + {right} in newer vims (which work also in insert mode)
B Goto previous word Note Ctrl + {left} in newer vims
[{ Goto previous {of current scope  
% Goto matching # If # else, {}, (), [],/**/ Must be one on line
Zi Toggle folds on/off  
Bookmarks
M {A-z} Mark position as {A-z} E. g. m
'{A-z} Move to position {A-z} E. g. 'A
'' Move to previous position  
'0 Open previous file Handy after starting Vim
Selection/whitespace
V Select visually Use cursor keys, home, end etc.
Shift + V Line select CTRL + V = column select
Delete Cut Selection  
"_ X Delete Selection Without updating the clipboard Or yank buffer. I remap X to this in my. vimrc
Y Copy Selection  
P Paste (after cursor) P is paste before cursor
"Ay Append selected lines to register Use lowercase A to initialise register
"AP Paste contents of  
GQ Reformat Selection Justifies text and is useful with: Set textwidth = 70 (80 is default)
= Reindent Selection Very useful to fix indentation for C code
> Indent Section Useful with Shift + V %
< Unindent Section Remember. To repeat and u to undo
: Set list! Toggle visible whitespace See also listchars in my. vimrc
Clipboard shortcuts
Dd Cut current line  
YY Copy current line  
D Cut to end of line  
Y $ Copy to end of line  
Search/replace
/Regexp Searches forwards for Regexp ? Reverses direction
N Repeat previous search N reverses direction
* Searches forward for word under cursor # Reverses direction
: % S/1/2/GC Search for Regexp 1 and replace with 2 in file C = confirm change
: S/1/2/g Search for Regexp 1 and replace with 2 in (visual) Selection  
Programming
K Lookup word under cursor in man pages 2 K means lookup in Section 2
: Make Run make in current directory  
CTRL +] Jump to tag CTRL + T to jump back levels. I map these to Alt + ?? In my. vimrc
Vim-T name Start editing where name is defined  
CTRL + {N, P} Scroll forward, back through autocompletions for word before cursor Uses words in current file (and supported ded files) by default. you can change to a dictionary for E. g: Set complete = K/usr/share/dicts/words note only works in insert mode
CTRL + x Ctrl + O Scroll through language specific completions for text before cursor "Intelliisense" For Vim (7 & later).: Help compl-Omni for more info. Useful for python, CSS, JavaScript, ctags,... note only works in insert mode
External Filters
: %! Filter Put whole file through Filter  
:! Filter Put (visual) selection through Filter  
:,! Command Replace current line with command output  
Map <F9>: W <CR> :! Python % <CR> Run current file with external program  


(Source: http://www.pixelbeat.org/vim.tips.html
)

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.