"Turn" Vim Ctag use method

Source: Internet
Author: User

The source I saw was not posted, I turned to http://www.cnblogs.com/feisky/archive/2012/02/07/2341932.htmlwindows. Many people use source insight to write and view code. Vim can be used under Linux, initially feeling vim like Notepad under Windows, and if used properly, it is not inferior to source insight.     Here I will do everything I can to make it clear how to turn vim into source insight, but you still need to think positively and have to grope for something yourself.     In order to avoid too wordy, I put the basic part behind, if you look more and feel too simple, then this article is not suitable for you, if you read the front of the question or do not understand what is said before, do not worry, there will be some necessary knowledge introduction. First, with a good system to bring software Ctags most of the UNIX system has ctags software, it can work well with vim. Use:    generate C language tag file, implement the jump between related C files. Usage:    1. Generate the tag file         in the current directory (run the command after the prompt):         $ctags-R &nbs P    -R represents recursive, recursive, which generates a label file for the C file in the current directory and its subdirectories. The last one. Represents the current directory.         After running the current directory there will be one more file tags, is the c tag index file.     2. Jump         1) use Vim to open an already tagged C file            2) Ctrl +] Find the cursor Where the label of the location is defined         3) ctrl+t back to the tab before the jump     NOTE: When running VIM, you must run the "tags" file in the same directory. Otherwise, run it will not find the "tags" file, but need to use ": Set tags=" command in Vim to set the "tags" file path. For a slightly larger item, you may be in anyDirectory to open vim, but in each directory to generate a tags file is not a good idea, then how to solve it? The method is to add a line to the. VIMRC:        Set tags=tags;/    This tells Vim to find the top-level directory when the tags file is not found in the current directory. Second, requires additional installation of the script: 1, taglisthttp://www.vim.org/scripts/script.php?script_id=273 If you download the address has changed, please go to www.vim.org to find the correct address, it is very simple. Use:    Open, you can display the overall structure of the source code, easy to jump. (People accustomed to the source insight must have recalled some of the ^_^) usage:    Download plugin and install, enter command in Vim when using        :tlist    To open/close the TagList window.     An easy way is to set shortcut keys, add a line in. vimrc       Nnoremap <silent> <F8>: Tlisttoggle <CR>    You can turn taglist on/off by pressing F8 in VIM.     More related configurations see the introduction to. VIMRC later. Iii. Basic Knowledge     convention: For convenience and accuracy, we agree that the command after "$" in this article is to run under the terminal, while the ":" Command is run in vim. Vim profiles are typically placed in the user's home folder, which is the non-root state of the directory where the terminal runs         $CD ~/   , and the file name is. vimrc.     Can't see? There are two possible:        1, the file name is preceded by a point that indicates a hidden file, and LS is required to add the-a option when viewing.             $ls-a        2, you have not built a. vimrc file, create aOK, first build an empty bar, you can continue to fill in the inside of things.             $touch .vimrc    Home folder There is also a. Vim folder, no self mkdir      &NBSP ; $mkdir ~/.vim    under the. Vim folder, build two subfolders: Plugin and doc        $mkdir ~/.vim/plugin    & nbsp   $mkdir ~/.vim/doc    Plugin folder to devolve the plugin, the Doc folder to the corresponding Help document.     Go to the next taglist (should we call it a script or a plugin?) It is placed under the plugin folder, then it should be a plug-in, and in vim.org, it is as scripts exist, then it should be a script. As an example, let's try to solve this.     Download is a zip package, put it in the ~/.vim directory, and then         $unzip filename.zip    It has automatically put Taglist.vim And Taglist.txt are placed in the plugin, Doc folder respectively.     Restart vim        $vim     run        :tlist    Discovery Next Did you have one more column on the side? If you open a C file, and you have generated a tags file, you should see some useful information in it.     At this time, TagList's help document is already in the ~/.vim/doc directory, but you're knocking at vim        : Help tlist    without any anti- Yes, that is because VIM has not obtained the tag in the Help document, the solution is under vim        : helptags ~/.vim/doc    Now, you       : Help tlist    See if there's a response?     about .vimrc    my own. VIMRC is also constantly improving, the process of improvement thanks to a lot of knowledge from the network, thanks to the friends who provide information, but also they prompted me to write this article. I put a part of my. VIMRC below and you can add these to your. VIMRC inside. ". VIMRC" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "for Ctags Et out of VI ' s compatible mode. Set nocompatible "Sets how many lines of the history VIM Har-Rememberset history=400" set to auto read when a file is changed From the Outsideset autoread "has the mouse enabled all the time:" If you need to copy from Vim, maybe you had to ': set Mouse= ' Firstset mouse=a "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "Colors and Fonts" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" " "Enable syntax Highlightsyntax enable" set Colorschemecolorscheme Elflord "endif" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" " "VIM userinterface" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""Set 7 lines to the curors away from the border-when moving vertical. Set so=7 ' Turn on WiLd menuset wildmenu ' always show current Positionset ruler ' The CommandBar is 2 highset cmdheight=2 ' show Line Numberset nu "Set backspaceset backspace=eol,start,indent" bbackspace and cursor keys wrap toset whichwrap+=<,> , h,l "Show matching Bracetsset showmatch" How many tenths of a second to Blinkset mat=2 "Highlight search Thingsset Hlsearch" Imediately Show the search resultset is "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" " "" "" "" "Enable folding, I find it very usefulset nofenset fdl=0" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" Set Expandtabset shiftwidth=2set ambiwidth=doubleset smarttab "set tab=4 spacesset ts= 4set lbrset tw=500set selection=inclusive    "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""   "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""O Indent width = 4 spaces   set sw=4    "Smart indet   set si   " C-style indenting& nbsp  set cindent "usage:select codes, press ' = ' key, the codes would autoindenting   " Wrap lines   se T wrap "Encoding Settingsif has (" Multi_byte ")    " Set fileencoding priority    If Getfsize (expand ("%" )) > 0        set fileencodings=ucs-bom,utf-8,cp936,big5,euc-jp,euc-kr,latin1    else& nbsp       Set fileencodings=cp936,big5,euc-jp,euc-kr,latin1    endif    "CJK environment Detection and corresponding setting    if V:lang =~ "^ZH_CN"         "Use cp936-support G BK, EUC-CN = = gb2312        set encoding=cp936        Set termencoding=cp936        Set fileencoding=cp936    ElseIf v:lang =~ "^ZH_TW"         "cp950, Bi G5 or EUC-TW&NBSP;       "is they equal to each other?        set encoding=big5      &NBS P Set termencoding=big5        set fileencoding=big5    ElseIf v:lang =~ "^ko"     &N Bsp   "Copied from someone ' s dotfile, untested        set encoding=euc-kr        Set termencoding=euc-kr        set fileencoding=euc-kr    ElseIf v:lang =~ "^JA_JP"   & nbsp     "Copied from someone ' s dotfile, unteste        set encoding=euc-jp        Set termencoding=euc-jp        set fileencoding=euc-jp    endif    "Detect UTF-8 locale, and replace CJK setting if needed    if V:lang =~ "utf8$" | | V:lang =~ "utf-8$"         set encoding=utf-8        set termencoding=utf-8  & nbsp     Set FILEENCODING=UTF-8&NBsp   endifelse    Echoerr "Sorry, this version of (g) Vim is not compiled with Multi_byte" endif "" "" "" "" "" "" "" " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "Plugins" "" "" Auto Pen When compare-Fileselselet tlist_auto_open=1 "Auto pen Tlist when Open a fileendif" set taglist window , delete the following line if you don ' t likelet tlist_use_right_window=1let tlist_auto_update=1 let Tlist_file_fold _auto_close=1 "Auto Close Tlist when exiting file.let Tlist_exit_onlywindow = 1 nmap <F7>: copen<cr>nmap <F6>:cclose<cr>

"Go" vim ctag use method

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.