VIM + taglist + ctags

Source: Internet
Author: User
Tags create directory
A lot of Linux software development is not actually performed in the case of X Window. At this time, we cannot start a graphical window based on X Window, in this case, the main editors we can use are vim and Emacs. (PS: Although Emacs and Vim are known as the gods of the two editors, they feel that Vim's function key settings are easy to use.) The following describes how to configure and use vim. You can set the vim environment to Google. The following describes the plug-in configuration. Ctags is first installed with ctags. We recommend that you use exuberant ctags. We can download its source code package from its official website, decompress, compile, and install it. The specific process is as follows: CD to the path of the decompressed file // execute the configure executable file before compilation. The configure program will detect the system configuration. /configure // After the configuration is completed, a configuration file will be obtained for make compilation. // use make to start compiling the source code. Make PS: the parsed command must use the root permission, note that after switching // compilation, we will use the built-in create directory command of ctags to create the installation directory of ctags. /makeinstalldirs // use make install to install make install.

During compilation, you may encounter "bash./configure permission denied" and other problems. Why? This is because the configure file is not an executable file. When you execute
$ Chmod + X./configure
You can directly
$./Configure
. That is to say, the solution to this error is to first execute
$ Chmod + X./configure
Or you can add a "bash:
$ Bash./configure

So far, the installation of ctags has been completed. You can use the ctags command to complete the installation during detection. Which ctags
// Check whether the ctags is successfully installed. If the command is successfully installed, the execution result is/usr/local/bin/ctags.
PS: in fact, the installation of exuberant ctags can be directly installed in the command line. It seems that Ubuntu 12.04 provides version 5.9, and its official website provides the highest version of 5.8, version issues may affect the specific use. We will install the taglist below. Just like the installation of ctags, We will download and decompress its source code package from its official website. The specific steps are as follows: Create the. Vim file (mkdir. Vim) in the home directory to store the vim plug-in. Then, decompress the source code package taglist we downloaded and copy the doc and plugins directories to the. Vim folder. Enter Vim in command mode and enter helptaglist ~ /. Vim/DOC completes the installation of taglist. Enter tlist in Vim. If the following screen is displayed, the installation is successful.

You can also use the following command to directly configure the vim installation path: sudo CP taglist/doc/taglist.txt/usr/share/Vim/vim73/doc/sudo mkdir/usr/share/Vim/vim73/plugin/
Sudo CP taglist/plugin/taglist. Vim/usr/share/Vim/vim73/plugin/has completed the installation of taglist and ctags, but the ctags and taglist are not linked yet. To do this, we need to modify ~ /. Vim/plugin/taglist. Vim file, find if! Exitsts (loaded_taglist) line, and add let tlist_ctags_cmd = "/usr/local/bin/ctags" PS: here, we need to note that when setting a straight line, we need to check where the executable path of the ctags is. We can go to the above directory, find the specific Executable File ctags and assign its path to tlist_ctags_cmd (for example, my path is/usr/local/bin/ctags) VIM + taglist + ctags read code in order to use VIM + taglist + ctags to read the code, we must first generate the symbolic information of functions and variables. In this step, we use ctags. For example, we use the source code package of the ctags we just downloaded as an example. // Generate the tag and execute ctags-R (-r recursion) // check whether the tags LS-l tags is generated. Can I check the generated tag, for detailed steps, enter tlisttoggle as follows to open the side window.

Use CTR and W to switch between the side window and the main window

 

After moving to the function of the soil, press enter to view the specific function.

 

Sometimes the function we want to view is defined in other code files. We only need to move the cursor to the function we want to view, and then press the CTR +] key to view the function, press CTR + O to jump back to the source file.

The following describes common taglist configuration options. You can configure them according to your habits:

 

The following describes common taglist configuration options. You can configure them according to your habits:

 

-The tlist_ctags_cmd option is used to specify the location of your exuberant ctags program. If it is not in the path defined by your path variable, you need to use this option to set it;

-If you do not want to display tags in multiple files at the same time, set tlist_show_one_file to 1. By default, tags in multiple files are displayed;

-If tlist_sort_type is set to "name", the taglist can be sorted by Tag name. By default, the tag is sorted by the order in which the file appears. Sort by TAG range (namespace or class). The todo list that has been added to the taglist is not supported yet;

-If you exit Vim when you want to use the taglist window as the last window, set tlist_exit_onlywindow to 1;

-If you want to display the taglist window on the right, set tlist_use_right_window to 1. It is displayed on the left by default.

-In gvim, if you want to display the taglist menu, set tlist_show_menu to 1. You can use tlist_max_submenu_items and tlist_max_tag_length to control the number of menu entries and the length of the displayed tag name;

-By default, When you double-click a tag, it will jump to the defined position of the tag. If you want to click the tag, set tlist_use_singleclick to 1;

-If you want to open the taglist window automatically after Vim is started, set tlist_auto_open to 1;

-If you want to automatically close the taglist window after selecting a tag, set tlist_close_on_select to 1;

-When the tag of multiple files is displayed at the same time, set tlist_file_fold_auto_close to 1, so that the taglist displays only the tag of the current file, and the tags of other files are collapsed.

-When Using tlisttoggle to open the taglist window, if you want to focus on the taglist window, set tlist_gainfocus_on_toggleopen to 1;

-If you want the taglist to always parse the tag in the file, set tlist_process_file_always to 1 regardless of whether the taglist window is opened;

-Tlist_winheight and tlist_winwidth can be used to set the height and width of the taglist window. Tlist_use_horiz_window: 1. Set the horizontal display of the taglist window;

Configure and use sudo Vim/etc/Vim/vimrc to edit the vim configuration document. Add the following command to it: "taglist Settings" Let tlist_auto_open = 1let tlist_ctags_cmd = '/usr/bin/ctags' Let tlist_show_one_file = 1let tlist_exit_onlywindow = 1 after loading the code file in Vim, you can use the following command to control the opening of taglisttlistopen (or directly tlist) and change the input focus to the tag List window, as shown in, tlistclose closes the tag List window. tlisttoggle switches the status of the tag List window (Open closing → close ), whether the focus of the tag List window is obtained depends on other configurations such as CTL-W + W or CTL-W + arrow key window switch (taglist is essentially a Vim separate window, therefore, you can use the CTL-W series shortcut keys to switch the window. In the taglist window, perform the following operations: Press F1: Open the help return key: jump to the tag definition where the cursor is located (for example, move the cursor to the main function and press the Enter key) O: create a window and jump to the tag definition. P: preview tag definition (still in the taglist window) space: display the tag prototype (such as the function prototype) U: update the tag list (for example, if a function is added to the source file and saved, you can press u In the taglist window) s: select the sorting field (I do not know what it means for the moment) D: Delete the taglist file where the cursor is located (for example, if two files f1.c are opened with VI, f2.c can delete the f1.c mark) X: N zoom in/out the taglist window +: expand (refer to the tag)-: Fold *: Expand All =: Fold all [[: move the cursor to the start point of the previous file]: move the cursor to the start point of the next file. Q: exit the taglist window. F1: Close the help.

 

Transferred from: bytes
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.