Use taglist in VIM

Source: Internet
Author: User
Tags prototype definition
From: http://blog.csdn.net/easwy

It is used for personal learning. If you have any interests, please notify me and delete it in time.

The help entry for the commands used in this section:

: Help helptags
: Help taglist.txt

The previous article describes how to use the Tag file in Vim. This article describes how to use the taglist plug-in.

Those who have used source insight must remember this function: Si can display the macros, global variables, functions, and other tags in the current file in the symbol window, and click the above tag with the mouse, to the position defined by the tag. You can sort the tag in alphabetical order, the class or scope to which the tag belongs, and the position where the tag appears in the file. If you switch to another file, the tag in this file is updated in the symbol window.

In vim, The taglist plug-in Implements similar functions. Some functions are weaker than Si, and some functions are stronger than SI. In addition, the taglist plug-in is still being improved!

To use the taglist plug-in, you must meet the following requirements:

1. Enable the vim file type automatic detection function;
2. the exuberant ctags tool is installed in the system, and the taglist tool can be found (because the taglist needs to be called to generate the Tag file );
3. Your Vim supports system () calls;

In the first article in this series (vimrc preliminary), we used the built-in vimrc example, which has enabled the file type detection function. In the previous article, we have also used exuberant ctags; System () calls are supported in common Vim versions (only SuSE Linux releases disable this function for security considerations ), therefore, we have met these three conditions.

Now let's go to http://www.vim.org/scripts/script.php? Script_id = 273 download the latest version of taglist plugin. The current version is 4.3.

After downloading the file ~ Decompress the/. Vim/directory, which will be in your ~ /. Vim/plugin and ~ Put one file in the/. Vim/doc directory:

Plugin/taglist. vim-taglist plugin

DOC/taglist.txt-taglist Help File

Note: Windows users need to decompress this plug-in your $ Vim/vimfiles or $ home/vimfiles directory.


Use the following command to generate a Help Tag (the following operations are performed in VIM ):

 

: Helptags ~ /. Vim/doc

 

After the Help Tag is generated, you can use the following command to view the help of the taglist:

 

: Help taglist.txt

 

Taglist provides a considerable number of features, which are configured in my vimrc as follows:

 

""""""""""""""""""""""""""""""
"Tag list (ctags)
""""""""""""""""""""""""""""""
If mysys () = "Windows" "sets the location of the ctags program in Windows
Let tlist_ctags_cmd = 'ctags'
Elseif mysys () = "Linux" "sets the location of the ctags program in Windows
Let tlist_ctags_cmd = '/usr/bin/ctags'
Endif
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

 

After this configuration, the following window is displayed when you enter ": tlistopen:

The taglist window appears on the right side of the screen. all tags defined in file C: macros, definitions, variables, functions, etc. You can also double-click a tag to jump to the location defined by the tag; you can also fold a certain type of tag (using Vim's line-breaking function) for easy viewing, just like macro and variable in the figure. For more functions, see the Help page of taglist. This article also introduces some common functions.


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;

In the taglist window, you can use the following shortcut keys:

 

<CR> jump to the position defined by the tag under the cursor. Double-click the tag with the mouse.
O display the tag under the cursor in a new window
<Space> display the prototype definition of the tag under the cursor
U update the tag in the taglist window
S. Change the sorting method and switch between name-based and order-based.
The X taglist window is zoomed in and out to facilitate viewing long tags.
+ Open a fold, same as Zo
-Fold the tag, same as ZC
* Open all folds, same as Zr
= Fold all tags, same as ZM
[[Jump to the previous file
] Jump to the next file
Q: Close the taglist window.
<F1> Show Help

You can use ": tlistopen" to open the taglist window and use ": tlistclose" to close the taglist window. Or use ": tlisttoggle" to switch between open and close. The following ing is defined in my vimrc. You can use the ", TL" key to open/close the taglist window:

 

Map <silent> <leader> TL: tlisttoogle <CR>

The taglist plug-in also provides a lot of ex commands, you can even use these commands to create a taglist session, and then load this session the next time you enter vim.

The taglist plug-in can also be used together with the winmanager plug-in, which will be described in the next article.


[Reference]

 

1. Vim Help File

2. http://vimcdoc.sourceforge.net/

3. taglist Help File

[Note]

This article can be freely used for non-commercial purposes. Indicate the source for reprinting.

Link: http://blog.csdn.net/easwy

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.