Complete the final configuration with vim code

Source: Internet
Author: User
Tags user definition

1. Let's take a look.

2. configuration method

<1>.

If the following effect is not specifiedCodePrompt shortcut key (such as Ctrl + p), to see the effect, do not really want visual assist.

1.1 code prompts for structure struct and enum enumeration:

 

1.2 User-Defined Function Code prompt

 

1.3 User-Defined variable code prompt

 

1.4 C ++ class method code prompt:

 

1.5 class attribute code prompt

 

1.6 C library code prompt

 

<2>. configuration method

2.1 install ctags and generate a Tag file

Install ctags

Xuqiang @ Ubuntu :~ /Documents/Vim/test $ sudo apt-Get install ctags

Generate a Tag file for the c header file in Linux. If you want to generate a Tag file for other libraries, the principles are the same:

Xuqiang @ Ubuntu :~ /Documents/Vim/test $ sudo ctags-f c -- recurse -- verbose where-F specifies the name of the Tag file. -- recurse indicates that all files and folders in the current directory are generated recursively. -- Verbose indicates that the current generation progress is printed on the console. It is best to save the generated Tag file to a specific directory. Here I am storing it in. VIM: xuqiang @ Ubuntu :~ /. Vim $ lsafter C-support exUtility-4.2.0 plugin Tags Autoload Doc ftplugin readme. csupport

2.2 download plug-ins

Download the plug-in (red for the plug-in configured in this section) and save it in ~ /. Vim/plugin.

| -- C. Vim | -- Neocomplcache. Vim | -- Snippet. Vim | -- supertab. Vim | -- taglist. Vim

2.3. vimrc configuration file

"Pr é requis tags

Set nocp filetype plugin on "Configure tags-add additional tags here or comment out not-used ones" load user definition tags "set tags + = ~ /. Vim/tags/STL set tags + = ~ /. Vim/tags/C "Linux header file tag" set tags + = ~ /. Vim/tags/linuxkernel "set tags + = ~ /. Vim/tags/SDL "set tags + = ~ /. Vim/tags/qt4 "build tags of your own project with Ctrl + F12 Map <C-F11> :! Ctags-r -- C ++-kinds = + p -- fields = + IAS -- extra = + q. <CR> noremap <F11> :! Ctags-r -- C ++-kinds = + p -- fields = + IAS -- extra = + q. <CR> inoremap <F11> <ESC> :! Ctags-r -- C ++-kinds = + p -- fields = + IAS -- extra = + q. <CR> "omnicppcomplete" Let metadata = 1 "Let omnicpp_globalscopesearch = 1" Let omnicpp_showaccess = 1 "Let metadata = 1" Let metadata = 1 "Let omnicpp_maycompletescope = 1" Let metadata = ["STD ", "_ glibcxx_std"] "automatically open and close the popup menu/preview window Au Cu Rsormovedi, insertleave * If pumvisible () = 0 | silent! Pclose | endif set completeopt = menuone, menu, longest, previewlet G: supertabretaincompletiontype = 2let G: supertabdefadefacompletiontype = "<C-X> <C-O>" Let G: acp_enableatstartup = 1let G: acp_ignorecaseoption = 1let G: acp_completeoption = '., w, B, k' "configuration for neocomplcache """""" "Disable autocomplpop. let G: ACP _ Enableatstartup = 0 "use neocomplcache. let G: neocomplcache_enable_at_startup = 1 "use smartcase. let G: neocomplcache_enable_smart_case = 1 "use camel case completion. let G: neocomplcache_enable_camel_case_completion = 1 "use underbar completion. let G: neocomplcache_enable_underbar_completion = 1 "set minimum syntax keyword length. let G: neocomplcache_min_syntax_length = 1 "set the max list in the pop Up menu. Increase the speedlet G: neocomplcache_max_list = 20 "define keyword. If! Exists ('G: neocomplcache_keyword_patterns ') Let G: neocomplcache_keyword_patterns ={} endif Let G: neocomplcache_keyword_patterns ['default'] = '\ H \ W *' Let G: neocomplcache_auto_completion_start_length = 1 "ignore letter caselet G: neocomplcache_enable_ignore_case = 1 "configuration for neocomplcache """" """""""""""""""""""""""""""""""""""""""" "auto complete () """""""""""""""""""""""""""""""""""""""" "": 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: charendifendf "auto complete () """""""""""""""""""""""""""""""""""""""" "line number """"""" "'set nu "line number """""""" """""""""""""""""""""""""""""""""""""""" "auto indent """"""""""" "set autoindentset cindent """""""" "auto indent """""""""""""""" """""""""""""""""""""""""""""""""""""""" "syntax on """""""""""""""""""""""" "syntax on """"""""""""""""" "syntax on """"""""""""""""""""""" """""""""""""""""""""

Note that by default, VIM does not load set tags + = ~ For the/. Vim/tags/C file, run the following command: neocomplcachecachingtags.

 

Code prompts for only one file that can be completed for the time being. The following sections will also introduce how to use Vim to manage project files and how to use Vim to debug CProgram.

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.