Basic Configuration
Terminal operation:
Vim ~ /. Vimrc
The configuration is as follows:
Set nocp "set compatible with set expandtab" set tabset shiftwidth = 4 "set the tab interval set tabstop = 4" four spaces represent a tabset STS = 4 set showmatch "the time mark in the input parentheses temporarily jump to the matching brackets and set autoindent "Set auto indent set number" to set whether to display the row set guifont = monospace \ 12 "Set Font size set encoding = UTF-8" set encoding for utf-8set fileencoding = utf-8set fileencodings = UCS-bom, UTF-8, gb18030, cp936, big5, EUC-JP, EUC-KR, latin1 "AutoComplete configuration autocmd filetype Python set omnifunc = complete # complete autocmd filetype JavaScript set omnifunc = complete # completejs autocmd filetype HTML set parameters = htmlcomplete # completetags autocmd filetype CSS set omnifunc = csscomplete # completecss autocmd filetype XML set omnifunc = xmlcomplete # completetags autocmd filetype PHP set omnifunc = phpcomplete # completephp autocmd filetype C set parameters = ccomplete # complete "##### automatic parentheses completion: inoremap () <ESC> I: inoremap) <c-r> = closepair (') <CR>: inoremap {{}< ESC> I: inoremap} <c-r >= closepair ('}') <CR>: inoremap [[] <ESC> I: inoremap] <c-r> = closepair (']') <CR>: inoremap <> <ESC> I: inoremap> <c-r> = closepair ('>') <CR> function closepair (char) If Getline ('. ') [col ('. ')-1] = A: Char return "\ <right>" else
Sudo apt-Get install exuberant-ctags
Return A: Char endif endfunction "###### auto-complete braces
CodeAuto-completion
First install ctags
Sudo apt-Get install exuberant-ctags
Create the. Vim folder in the main directory, and then create several subdirectories:
CD. vimmkdir pluginmkdir docmkdir tags
DownloadOmnicppcomplete, click to download
Decompress the package to produce three folders: After, autoload, and Doc. I directly put these three folders under the. Vim folder.
You also need to download an object to generate the CPP index-libstdc ++ header file
Decompress the terminal CD to the decompressed directory and use ctags to produce the index.
Ctags-r -- Sort = 1 -- C ++-kinds = + p -- fields = + IAS -- extra = + Q -- language-force = C ++-f cpp.
The directory contains an additional CPP file, which is the generated index file.
Copy the CPP file ~. In the vim/tags folder.
Last Modified ~ /. Vimrc. Add at the end
"-- Omnicppcomplete setting -- set tags + =/home/TAO /. vim/tags/cppset completeopt = menu, menuonefiletype plugin indent onlet omnicpp_maycompletedot = 1 "AutoComplete. let omnicpp_maycompletearrow = 1 "AutoComplete with-> let omnicpp_maycompletescope = 1" AutoComplete with: Let omnicpp_selectfirstitem = 2 "select first item (but don't insert) let omnicpp_namespacesearch = 2 "Search namespaces in this and supported ded fileslet labels = 1" show function prototype in popup windowlet omnicpp_globalscopesearch = 1let omnicpp_displaymode = 1let comment = ["STD"]
Restart vim and test:
File Browser
When editing multiple files, if you do not have the file browsing function, switching files will be very painful ..
The plugin used here is nerdtree. Click here to download it.
After decompression, copy the. vimand. txt files under the plug-in ~ /. Vim directory.
# Command line CP plugin/nerd_tree.vim ~ /. Vim/plugin/cp doc/nerd_tree.txt ~ /. Vim/doc
Open vim and run the following command:
: Nerdtre
Use of plug-ins:
Go to the tree interface of the current directory, and move the selected directory or file through the keyboard's upper and lower keys
There is a plus sign in front of the directory. Press enter to open the directory. The front of the file is the minus sign. Press enter to display the content of the file in the right window and focus on the right side of the cursor.
CTR + W + H cursor focus left Tree directory, CTRL + W + L cursor focus right file display window. Press Ctrl + W multiple times, and the cursor is automatically switched in the left-right window
Click the cursor to focus on the left-side tree window? The help of nerdtree is displayed. Why? Disable help display
Enter: Q press enter to close the window where the cursor is located
This articleArticleReprinted from: http://blog.csdn.net/qp120291570/article/details/8864916