This article from http://blog.sina.com.cn/s/blog_7745fc86010147h6.html
From example
First, install the vim editor.
Sudo apt-Get install vim-GTK
After the installation is complete, we will install the ctags plug-in, which is mainly used to generate an index file generated by the ctags program. The ctags program is called "Exuberant ctags ", it is a substitute for the ctags program on UNIX and is more powerful than it. It is the default ctags program in most Linux distributions. so what is the tags file used? What if you read a function call, a variable, a macro, and so on while reading the program and want to know where they are defined? Use grep? It will find a lot of irrelevant things. Currently, it's popular to use <c-]>. Who knows? When the cursor is on a function or variable,
Press "Ctrl +]" And the cursor will automatically jump to its definition. It's amazing. You don't have to envy Visual Studio programmers any more. Start to envy me ~ _~.
On this site: http://ctags.sourceforge.net, download a file similar to ctags-5.8.tar.gz down:
Run the following command to decompress and install the tool:
$ Tar-xzvf ctags-5.8.tar.gz
$ Ctags-5.8 CD
$./Configure
$ Make
$ Sudo make install
Installation is complete.
Then you can start using ctags by remembering the following seven commands: (very simple, huh, huh)
1. $ ctags-R * ($ is a Linux shell prompt)
2. $ vi-T tag (replace the tag with the variable or function name you want to find)
3.: TS (the command starting with ":" In tags list is the command line mode command in VI)
4.: TP (TP note: tags Preview) --- this command is not commonly used and does not need to be remembered
5.: tn (TN mnemonic: tags next) --- this command is not commonly used and does not need to be remembered.
6. CTRL +]
7. CTRL + T
For Article 1, open the terminal in the Code directory, or use CD to switch to the terminal, and then enter $ ctags-R. We can see that a tags file is generated, then we use the second command, for example, Input $ vim-t Main, which indicates that we use Vim to open the main function in the directory. Then we should be able to see the main function on the terminal, if you want to find the definition of a function or variable, you can directly move the cursor to this place and press Ctrl +]. in this way, you can directly jump to the source file defined by this variable or function, and position the cursor to this line. You can use "Ctrl + T" to return the original location. Even if you use "Ctrl +]" for n times to find n variables, you can press "Ctrl + T" for n times to return to the originally opened file.
. Pai_^
Next, let's take a look at how to manually set Vim In ubuntu. The following describes a common method.
First, we can create. vimrc file, which is hidden by default, so we need to use the chrl + h combination key to display it, and then set some Vim configuration usage in it, if you are the same as me, it is only convenient for VIM to read the code, then I suggest you set some basic functions: Use gedit. open vimrc and enter:
Set syntax = on
"Color Scheme
Colorscheme torte
"Remove the input error prompt sound
Set noeb
"Confirmation pops up when processing unsaved or read-only files
Set confirm
"Auto indent
Set autoindent
Set cindent
"Automatic line feed
Set wrap
"Line feed
Set linebreak
"Tab key width
Set tabstop = 4
"Unified indent to 4
Set softtabstop = 4
Set shiftwidth = 4
"Do not use spaces instead of tabs
Set noexpandtab
"Use a tab at the beginning of a row and segment
Set smarttab
"Display row number
Set number
"Number of historical records
Set history = 1000
"Do not generate temporary files
Set nobackup
Set noswapfile
"Case-insensitive search
Set ignorecase
"Search for highlighted characters by character
Set hlsearch
Set incsearch
"Intra-row replacement
Set gdefault
"Encoding settings
Set ENC = UTF-8
Set fencs = UTF-8, ucs-bom, shift-JIS, gb18030, GBK, gb2312, cp936
"Language settings
Set helplang = Cn
Set encoding = utf8
Set langmenu = zh_CN.UTF-8
Set imcmdline
Source $ vimruntime/delmenu. Vim
Source $ vimruntime/menu. Vim
"Set the font.
Set guifont = liberation \ mono \ 12
"Set guifont = fixedsys \ Excelsior \ 3.01 \ 14
Let tlist_show_one_file = 1 "the tag of multiple files is not displayed at the same time, only
Let tlist_exit_onlywindow = 1 "if the taglist window is the last window, exit Vim
Let tlist_use_right_window = 1 "display the taglist window on the right
Let tlist_auto_open = 1 "if you want to open the taglist window automatically after Vim is started
Save the settings.
The next step is to install the taglist plug-in. Note that the taglist depends on the ctags, so you must install the ctags first. Otherwise, the taglist cannot be installed!
To http://vim.sourceforge.net/scripts/download_script.php? Src_id = 6416 find the taglist installation package
Then decompress the package. You can right-click the package and find a command option. decompress the package directly here and click it. Instead, run the command # unzip-D taglist taglist_42.zip without installing the command # unzip-D taglist taglist_42.zip.
# Cd taglist
To decompress the package. Then run the following command:
Cp doc/taglist.txt/usr/share/Vim/vim73/doc/
CP plugin/taglist. Vim/usr/share/Vim/vim73/plugin/
Different Versions of VIM vary, so you may be using another version of VIM **, not necessarily 73.
This completes
Jason @ Ubuntu :~ /Lidar/3530/working-copy $ Vim 3dmapping_thread.cpp open the source file and enter tlistopen to display the tag column on the right. The window on the right is the taglist window described above, which lists main. the tags in the C file are classified according to "typedef", "variable", and "function. move the cursor over vimmain, the red box on the left, press enter, the source program will automatically jump to the definition of vimmain, the red box on the right. this is the most basic and commonly used taglist operation.
I will teach you a common operation. If you do not want to redirect the source code when browsing the taglist window, but want to see the complete expression of the tag in the source code, you can move the cursor to the tag you want to see, and then press the Space key, in the command bar below, the yellow box below, the complete syntax of the tag in the source code is displayed, rather than jump to the source code.
Input: Q introduces taglist,
Input: tlistopen switches between source code and tag.
Next, install the winmanage plug-in to display the directory.
To http://www.vim.org/scripts/script.php? Script_id = 95 download the plug-in and decompress it,
Then;
Sudo CP winmanager.txt/usr/share/Vim/vim73/doc/
Sudo CP winfileexplorer. Vim/usr/share/Vim/vim73/plugin/
Sudo CP winmanager. Vim/usr/share/Vim/vim73/plugin/
Sudo CP wintagexplorer. Vim/usr/share/Vim/vim73/plugin/
In. vimrc, enter:
Let G: winmanagerwindowlayout = 'fileexplorer | taglist'
Nmap wm: wmtoggle <CR>
.
Next try the effect:
Jason @ Ubuntu :~ $ Vim 3dmapping_thread.cpp
Then press WM in normal mode, and two windows, directories and taglist, are displayed on the left. After pressing WM, it disappears. Every time you press the ENTEL key to open the corresponding function or directory. : Switch between tlistopen and: Q.