Vim basic configuration and frequently used commands

Source: Internet
Author: User

Vim Advantages and application scenarios

The advantages of Vim pure text editing and the perfect fusion of Linux provide the command line . Only assume that the SSH to the server to operate, then this situation can only use VIM. Vim is also one of the most powerful general-purpose text editors, and Vim is quite advantageous for situations where you need to edit different texts. Therefore, it is very necessary to master the basic use of vim.


Vim is based on the VI with a lot of new features developed. Gvim adds a graphical front-end to vim. Assuming that vim is used under Windows, you can install the latest gvim directly.


A major VIMRC configuration file is given here. No matter what plug-ins are configured, the theme is changed to a evening darkened theme. The font has been changed to a consolas-wide font. and the line number. Indentation, search, and so on have done some basic settings. and have done the key mapping <ESC> ii,i is to switch to insert mode, high-speed double-click I, then switch back to normal mode is very handy.
    • Linux generally in the user home folder to build a. vimrc file to make changes. Instead of changing the global configuration under the/etc/vim folder, it affects all users.

    • Windows VIMRC is located under the C:\Program files (x86) \vim folder. The name is _VIMRC, assuming that the everything is installed, the direct search VIMRC a step can be located.

Vim configuration file VIMRC
"-----------------------------------------------------------------------------------: IMAP II <Esc> "Key mapping <ESC> II" appearance colorscheme evening "Configuring color theme Set Guifont=consolas:h12"                          Set the font and size set number "show line numbers set guioptions-=t" hides the toolbar set ruler                       "Open status bar ruler set Cursorline" highlight current row set Syntax=on "syntax highlighting set Showmatch                   "Highlight matching parentheses set matchtime=3" matches the time in parentheses highlighting (in 0.1s) set scrolloff=10 "Cursor to the bottom of the screen to keep 10 lines (the cursor is at the bottom of the screen looking very uncomfortable) set lines=35 columns=118" size at startup: Winpos 177 51 "Start When the "search set ignorecase smartcase" search ignores uppercase and lowercase, but remains uppercase and lowercase sensitive set hlsearch "highlight Search SE                        T Incsearch "Incremental search, verbatim Fugauliang" operation set clipboard+=unnamed "shared clipboard set ShowCmd "The input command is displayed. Set iskeyword+=_,$,@,%,#,-"Do not wrap a word with words such as the following symbol to cut set Noexpandtab" without a space instead of tab (makefile is often used by the T                        AB) Set tabstop=4 "Tab key width set shiftwidth=4" row staggered width set mouse=a Mouse can use set Autoindent to inherit the indentation of the previous line. Especially suitable for multi-line gaze "backup set confirm" is not saved or simply read, popup confirm set Nobackup "does not generate backup file Setl                   Ocal noswapfile "Do not generate swap file set Bufhidden=hide" hides set when buffer is discarded noerrorbells "Do not emit warning" decode set fenc=utf-8 set fencs=utf-8,usc-bom,euc-jp,gb18030,gbk,gb2312,cp936
Vim's frequently used commands
Efficiency.      # repeated recent text operations # file: Q # Exit Q->quit:w # Save w->write:q! # Force exit does not save: Wq # Save after exiting ZZ # Save after exiting, same as: WQ # cursor Movement HJKL # Most important left bottom right. Move a character ZZ # cursor do a line move to the middle of the screen W # move forward one word. The cursor stops at the top of the word B # moves backwards a word, the cursor stops at the word header e # with W, the cursor stops at the end of the word GE # with B, the cursor stops at the end of the word 0 # The first character of the line (same as <HOME>) ^ # Bank first non-whitespace character $ # move to end of line (same <END>) GG # move to file Header G # Move to end of file: N # jump to Nth Line FX # move to The first character after the cursor find Fx # with F, reverse Ctrl+d # Scroll down half screen ctrl+u # scroll up half screen ctrl+f # scroll down half screen ctrl+b # scroll up half screen% #        Jump to a pair of parentheses (often used) (# Move to the beginning of the current sentence) # move to the next sentence Start H # move page top H-&GT;HIGHM # move Page Middle M->middlel # move the bottom of the page l->low# find/test # Find text, (remember to use the regular table), and then n down. N up N->next?test # Find text. Reverse * # Find the word with the same word as the cursor # # Look up and the word with the same word as the cursor: Nohlsearch # Turns off the currently highlighted results (input: Noh press <Tab> The key can be self-complementary) # Replace RA # The current character is replaced with a, r->replace:%S/OLD/NEW/G # Replace all of the full match g->global:%s/old/new/# Replace all rows The first match: S/old/new/g # replaces the current row all matches: s/old/new/# Replaces the current row the first horse With # Insert a # Insert A->appenda # at current line end insert I # at current position Insert I->inserti # Insert O # at current line After inserting a line o # Insert a line before the current line s # delete the cursor character, and enter the insertion mode s # Delete the line where the cursor is located, and enter the insertion mode # Check V # from the current position of the cursor, the place where the cursor passes is selected, Press V to end (similar <shift>+ direction) V->view Visual Mode v # from the current line of the cursor, the cursor passes through the line will be selected, and then click V End # Delete D # Delete selected (delete the content to the buffer can       Enough to be pasted, equivalent to cut) D->deletex # Delete current character 3x # Delete current cursor backwards three characters (Vim used < number >+< command > combination) DD # Delete current line DW # Delete the character of the cursor to the beginning of the next word DW, delete wordd$ # Delete the current character to the end of the line%-> regular is the end of the line 3d # Delete the current line starts three lines J # merge two rows (that is, delete when the line ends        Line character) j->join# undo U # Undo U->undou # Undo action on Positive Row Ctrl+r # Redo Undo # Copy Paste y # Copy checked yy # copy current line P # paste after the current cursor. If you copy a row, paste it to the next line P-pastep # pastes the DDP # swap the current line and the next line (skillfully applied cut paste) XP # Swap the current character and the next

Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.

[Http://blog.csdn.net/thisinnocence]

Vim basic configuration and frequently used commands

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.