Install and configure the vim plug-in ctags and the vim plug-in ctags
Recently I used the ctags plug-in. I found that many of the information on the Internet is not clear enough. I have been exploring Multiple blogs. Today, I have finally configured it successfully and recorded it here for future reference.
Plugin introduction:
Ctags is a plug-in vim. It enables users to jump back and forth between functions with call relationships. It is mostly used to view functions, variables, or Macros in the source code.
Plugin installation:
1. Download The ctagscompressed package from http://ctags.sourceforge.net;
2. decompress the compressed package to a folder in the user directory (for example, I put it in/home/willson/code, and code is the storage location of various project codes );
3. Enter the decompressed file and perform the three-pronged operation:./configure, make, and sudo make install.
Plug-in Configuration:
Enter the command: sudo ctags-R (figure 1) in the parent directory where your various engineering codes are located (my name is/home/willson/code). Press enter, you will find that the tags file is added to this parent directory. (Note that this tags file is relative to all projects under this parent directory. If a project is renamed or a new project is introduced, delete the original tags, and then generate a new tags file according to this method), 2:
Figure 1
Figure 2
There are two methods to use the ctags plug-in:
First, the exact setting method.
Use vim to open a project file (such as/home/willson/code/tt. c) set the tags source in command line mode, that is, set tags =/home/willson/code/tags, 3:
Figure 3
Then, move the cursor to the call function in the file and press "Ctrl +]" to automatically jump to the call function. Then press "Ctrl + t" and jump back.
Second, general settings.
Open the. vimrc file in the user directory. If there is no file, create one by yourself. The path is/home/willson/. vimrc, and write two lines in it:
set tags=tags;set autochdir
Save and exit. Then, you can jump back and forth between call functions of all engineering codes under/home/willson/code.
In addition, when editing the. vimrc file, you may find that the system automatically generates the. vimrc ~ Files and tables are excited. Files whose names end with wavy lines are backed up of the original file, which is equivalent to "Original Name _ bak" in windows ".