My VIM configuration script

Source: Internet
Author: User

Own VIM configuration script, with independent intellectual property rights (refer to a little others), only use a plug-in ctags, the main implementation of the function:

    • Auto-complete brackets, double quotes, single quotation marks, including {}, (), "", "", as long as you enter the left part of the symbol, auto-complete, and automatically move the cursor to the inside of the symbol in insert mode
    • Press ENTER inside {}, () to automatically wrap two lines, move the cursor to the first row in two lines, and complete the auto indent
    • Command mode, shortcut key "s", save the file, save the file at the same time, automatically refresh tags, press CTRL +] and CTRL+T implementation function, structure, class automatic jump and return.
    • Command mode, shortcut key "Q", Exit vim
    • In insert mode, the right side of the cursor is}, ",", press the TAB key to automatically jump out of the symbol, if you do not know the symbols, complete the indentation action
    • In command mode, press "T" to list all open files
    • In command mode, press ";" to bring up the command input line
    • In command mode, you can toggle between open buffer by pressing <-and
    • You can click with the mouse
    • Highlight cursor in the row
    • Status Highlight current Open file information
    • F4 closing the current buffer

Other more complex configurations, slowly replenished later

"set the Help document to ChineseSet helplang=cn"Set EncodingSet fileencodings=utf-8, gb2312,gb18030,gbk,ucs-bom,cp936,latin1"Highlight Displaysyntax enable syntax on"number of rows displayedSet number"Setting the TAB keySet tabstop=4  "Set IndentSet softtabstop=4Set Shiftwidth=4 "Set auto IndentSet Autoindentset cindent"do not generate swap files and backup filesSet Noswapfileset nobackup"Set Check spelling (feel used with no effect)"set Spell "Displays the line number where the cursor is locatedSet Cursorline"Displays the line number and column number of the cursorSet Ruler"the mouse can be clicked in the bufferSet mouse=aset Showmode"Highlight Search KeywordsSet Hlsearch"Smart SearchSet Incsearch"Search ignores caseSet ignorecase"Display the command enteredSet ShowCmd"Open File Type detectionfiletype Onfiletype plugin on"set up common symbol auto-completion (note: Inore refers to various operating modes of VIM)Inoremap (() <ESC>Iinoremap [[]<ESC>Iinoremap" ""<esc>iInoremap' "'<esc>iInoremap {{}<esc>I"custom shortcut keys (note here the <cr> denotes the character ' < ' C ' r ';, in the configuration script equivalent to the ENTER key)"Save and exitNmap S:W<cr>Nmap q:q<cr>"use Left and RIGHT arrow keys to switch between different bufferNmap <Left>:bp<cr>Nmap<Right>:bn<cr>"F4 Closing the current bufferNmap <F4>:bd<cr>Nmap f:e"Switch between open filesNmap T:ls<cr>nmap B:bnmap;:"in edit mode, press ' {' or ' (', the parentheses will be auto-complete, the cursor moves into parentheses, and the ' Enter ' key is pressed to make the wrap and indentInoremap <CR> <c-r>=enterskip () <CR>functionEnterskip () LetChar= Getline (".") [Col (".") -1]if Char=='}'||Char==')'return"\<cr>\<esc>o"Elsereturn"\<cr>"ENDIFENDF"in edit mode, if the right side of the cursor is the following symbols, press the ' Tab ' key to automatically jump out of parentheses, and vice versa the normal Tab key functionInoremap <Tab> <c-r>=tabskip () <CR>functionTabskip () LetChar= Getline (".") [Col (".") -1]if Char=='}'||Char==']'||Char=='"'||Char=='>'||Char==')'||Char=="'"return"\<right>"Elsereturn"\<tab>"ENDIFENDF"pending scripts (scripts that are not yet understood)"Inoremap] <c-r>=closepair ('] ') <CR> (this script to be determined)"Inoremap < <><LEFT>"Inoremap * **<left>"use curly braces to cross-line auto-complete functionality only for c,cpp files"inoremap) <c-r>=closepair (') ') <CR>"autocmd FileType c,cpp,go inoremap {{<cr>}<esc>o"use curly braces for the sh file for the current line auto-complete function"autocmd FileType sh inoremap {{}<esc>i"Inoremap} <c-r>=closepair ('} ') <CR>  "function! Closepair (char)"if Getline ('. ') [Col ('. ')-1] = = A:char"return"\<right>""Else"return A:char"endif"endfunction  "ctags Auto Completion (executes ctags-r each time the file is saved)"--languages=c++,c,java,make,sh, that's what the language of this ctags scan is made of."--c++-kinds=+px instructs Ctags to scan some function declarationsAutocmd Bufwritepost * Call System ("ctags--tag-relative=yes-f ~/.tagsdir/tags-r--languages=c++,c,java,make,sh,--c++-kinds=+px--fields=+aiKSz-- Extra=+q")"autocmd bufwritepost * Call System ("Ctags--tag-relative=yes-f/home/satan/.tagsdir/tags-r *") "because each time the file is saved, the tags file will be refreshed, but the file is located in the current folder under the refresh, so the next time you use a jump, there will be multiple choices, so directly specify a tags generated folderSet tags=/home/satan/.tagsdir/Tagsset Autochdir"display information about the current file in the status barSet laststatus=2      "Always show status barHighlight Statusline cterm=bold ctermfg=black ctermbg=Yellow"get current path, convert $home to ~function!CurDir () let CurDir= Substitute (GETCWD (), $HOME,"~","g") return Curdirendfunctionset statusline=[%n]\%f%m%r%h\ \|\ \pwd: \%{curdir ()}\ \ \|%=\|\%l,%c\%p%%\ \|\ ascii=%b,hex=%b%{((&fenc==\"\ " ) \" \ ": \" \ \|\ \ ". &fenc)}\ \|\%{$USER}\ @\%{hostname ()}

My VIM configuration script

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.