Incomplete Vim configuration Manual

Source: Internet
Author: User

Make up your mind to configure vim.

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 return a: Char endif endfunction "###### auto-complete braces

Code auto-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

Download omnicppcomplete. Click here 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 with .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 included fileslet OmniCpp_ShowPrototypeInAbbr = 1 " show function prototype  in popup windowlet OmniCpp_GlobalScopeSearch=1let OmniCpp_DisplayMode=1let OmniCpp_DefaultNamespaces=["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:

:NERDTree

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

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.