中国Linux论坛首页 技术论坛| 文章荟萃| 藏经阁| 项目计划| 在线调查| 网站镜像| 软件仓库| 关于本站|

Linux 环境下的程序设计
   >> C/C++编程版
此话题阅读次数: 24549

此话题的页数:1 | 2 | 3 | (显示全部)   打印
lang2
(enthusiast)
03-01-22 19:36
附加档案
[精华] Vim 精品插件 1 -- taglist  

Vim 有一个强大的脚本语言,很多人用这个语言为Vim编写
了很多的插件 [1]. 其中有些非常实用.我将开始为大家介绍
其中的一些.希望能够提高大家的工作效率. Vim 就是为了
效率而设计的.

这次将介绍的是 taglist, 能够列出源文件中的tag(function,
class, variable, etc)并跳转.请看附图.

连接:
http://vim.sourceforge.net/script.php?script_id=273

下载:
http://vim.sourceforge.net/script_download.php?src_id=1657

安装:
把下载到的.vim文件拷贝到Vim下的plugin目录.需要 ctag [2].

使用:
:Tlist
我用:
nmap <F8> :Tlist<CR>




[1] http://vim.sf.net
[2] http://ctags.sourceforge.net

编辑者: lang2 (03-01-22 20:31)

文章选项: 打印

晓寒
(member)
03-01-22 21:49
[精华] Re: Vim 精品插件 1 -- taglist 新 [re: lang2] 

网址访问不了。


昨夜西风凋碧树,独上高楼,望尽天涯路....

文章选项: 打印

lang2
(enthusiast)
03-01-22 22:08
附加档案
[精华] Re: download taglist.vim 新 [re: lang2] 

unzip it to get taglist.vim

http://vimcdoc.sf.net

编辑者: lang2 (03-01-22 22:11)

文章选项: 打印

lang2
(enthusiast)
03-01-22 22:09
附加档案
[精华] Re: download ctag 新 [re: lang2] 

source code

http://vimcdoc.sf.net

文章选项: 打印

lang2
(enthusiast)
03-01-22 22:10
[精华] Re: Description 新 [re: lang2] 

taglist.vim : Tag listing for various programming language source files in a Vim window
?script karma?
Rating 546/178, Downloaded by 3776

created by
Yegappan Lakshmanan
?
script type
utility
?
description
Overview
The "Tag List" plugin provides the following features:
1. Opens a vertically/horizontally split Vim window with a list of tags
?? (functions, classes, structures, variables, etc) defined in the current
?? file.
2. Groups the tags by their type and displays them in a foldable tree.
3. Automatically updates the taglist window as you switch between
?? files/buffers.
4. When a tag name is selected from the taglist window, positions the cursor
?? at the definition of the tag in the source file
5. Automatically highlights the current tag name.
6. Can display the prototype of a tag from the taglist window.
7. Displays the scope of a tag.
8. Can optionally use the tag prototype instead of the tag name.
9. The tag list can be sorted either by name or by line number.
10. Supports the following language files: Assembly, ASP, Awk, C, C++,
????Cobol, Eiffel, Fortran, Java, Lisp, Lua, Make, Pascal, Perl, PHP,
????Python, Rexx, Ruby, Scheme, Shell, Slang, Sql, TCL, Verilog, Vim and
????Yacc.
11. Runs in all the platforms where the exuberant ctags utility and Vim are
????supported (this includes MS-Windows and Unix based systems).
12. Runs in both console/terminal and GUI versions of Vim.
13. The ctags output for a file is cached to speed up displaying the taglist
????window.
This plugin relies on the exuberant ctags utility to generate the tag
listing. You can download the exuberant ctags utility from
http://ctags.sourceforge.net. The exuberant ctags utility must be installed
in your system to use this plugin. You should use exuberant ctags version
5.3 and above.??There is no need for you to create a tags file to use this
plugin.
This script relies on the Vim "filetype" detection mechanism to determine
the type of the current file. To turn on filetype detection use
??????????????:filetype on
This plugin will not work in 'compatible' mode.??Make sure the 'compatible'
option is not set. This plugin will not work if you run Vim in the
restricted mode (using the -Z command-line argument). This plugin also
assumes that the system() Vim function is supported.
Installation
1. Copy the taglist.vim script to the $HOME/.vim/plugin directory.??Refer to
?? ':help add-plugin', ':help add-global-plugin' and ':help runtimepath' for
?? more details about Vim plugins.
2. Set the Tlist_Ctags_Cmd variable to point to the exuberant ctags utility
?? path.
3. If you are running a terminal/console version of Vim and the terminal
?? doesn't support changing the window width then set the Tlist_Inc_Winwidth
?? variable to 0.
4. Restart Vim.
5. You can use the ":Tlist" command to open/close the taglist window.
Usage
You can open the taglist window from a source window by using the ":Tlist"
command. Invoking this command will toggle (open or close) the taglist
window. You can map a key to invoke this command:
??????????????nnoremap <silent> <F8> :Tlist<CR>
Add the above mapping to your ~/.vimrc file.
You can close the taglist window from the taglist window by pressing 'q' or
using the Vim ":q" command. As you switch between source files, the taglist
window will be automatically updated with the tag listing for the current
source file.
The tag names will grouped by their type (variable, function, class, etc)
and displayed as a foldable tree using the Vim folding support. You can
collapse the tree using the '-' key or using the Vim zc fold command. You
can open the tree using the '+' key or using hte Vim zo fold command. You
can open all the fold using the '*' key or using the Vim zR fold command
You can also use the mouse to open/close the folds.
You can select a tag either by pressing the <Enter> key or by double
clicking the tag name using the mouse.
For tags with scope information (like class members, structures inside
structures, etc), the scope information will be displayed in square brackets
"[]" after the tagname.
The script will automatically highlight the name of the current tag.??The
tag name will be highlighted after 'updatetime' milliseconds. The default
value for this Vim option is 4 seconds.??You can also use the ":TlistSync"
command to force the highlighting of the current tag. You can map a key to
invoke this command:
??????????????nnoremap <silent> <F9> :TlistSync<CR>
Add the above mapping to your ~/.vimrc file.
If you place the cursor on a tag name in the "Tag List" window, then the tag
prototype will be displayed at the Vim status line after 'updatetime'
milliseconds. The default value for the 'updatetime' Vim option is 4
seconds. You can also press the space bar to display the prototype of the
tag under the cursor.
By default, the tag list will be sorted by the order in which the tags
appear in the file. You can sort the tags either by name or by order by
pressing the "s" key in the taglist window.
You can press the 'x' key in the taglist window to maximize the taglist
window width/height. The window will be maximized to the maximum possible
width/height without closing the other existing windows. You can again press
'x' to restore the taglist window to the default width/height.
You can open the taglist window on startup using the following command line:
??????????????$ vim +Tlist
You can use the ":TlistShowPrototype" command to display the prototype of
a function in the specified line number. For example,
??????????????:TlistShowPrototype 50
If the line number is not supplied, this command will display the prototype
of the current function.
Configuration
By changing the following variables you can configure the behavior of this
script. Set the following variables in your .vimrc file using the 'let'
command.
The script uses the Tlist_Ctags_Cmd variable to locate the ctags utility.
By default, this is set to ctags. Set this variable to point to the location
of the ctags utility in your system:
??????????????let Tlist_Ctags_Cmd = 'd:\tools\ctags.exe'
By default, the tag names will be listed in the order in which they are
defined in the file. You can alphabetically sort the tag names by pressing
the "s" key in the taglist window. You can also change the default order by
setting the variable Tlist_Sort_Type to "name" or "order":
??????????????let Tlist_Sort_Type = "name"
Be default, the tag names will be listed in a vertically split window.??If
you prefer a horizontally split window, then set the
'Tlist_Use_Horiz_Window' variable to 1. If you are running MS-Windows
version of Vim in a MS-DOS command window, then you should use a
horizontally split window instead of a vertically split window.??Also, if
you are using an older version of xterm in a Unix system that doesn't
support changing the xterm window width, you should use a horizontally split
window.
??????????????let Tlist_Use_Horiz_Window = 1
By default, the vertically split taglist window will appear on the left hand
side. If you prefer to open the window on the right hand side, you can set
the Tlist_Use_Right_Window variable to one:
??????????????let Tlist_Use_Right_Window = 1
To automatically open the taglist window, when you start Vim, you can set
the Tlist_Auto_Open variable to 1. By default, this variable is set to 0 and
the taglist window will not be opened automatically on Vim startup.
??????????????let Tlist_Auto_Open = 1
By default, only the tag name will be displayed in the taglist window. If
you like to see tag prototypes instead of names, set the
Tlist_Display_Prototype variable to 1. By default, this variable is set to 0
and only tag names will be displayed.
??????????????let Tlist_Display_Prototype = 1
The default width of the vertically split taglist window will be 30.??This
can be changed by modifying the Tlist_WinWidth variable:
??????????????let Tlist_WinWidth = 20
Note that the value of the 'winwidth' option setting determines the minimum
width of the current window. If you set the 'Tlist_WinWidth' variable to a
value less than that of the 'winwidth' option setting, then Vim will use the
value of the 'winwidth' option.
By default, when the width of the window is less than 100 and a new taglist
window is opened vertically, then the window width will be increased by the
value set in the Tlist_WinWidth variable to accomodate the new window.??The
value of this variable is used only if you are using a vertically split
taglist window.??If your terminal doesn't support changing the window width
from Vim (older version of xterm running in a Unix system) or if you see any
weird problems in the screen due to the change in the window width or if you
prefer not to adjust the window width then set the 'Tlist_Inc_Winwidth'
variable to 0.??CAUTION: If you are using the MS-Windows version of Vim in a
MS-DOS command window then you must set this variable to 0, otherwise the
system may hang due to a Vim limitation (explained in :help win32-problems)
??????????????let Tlist_Inc_Winwidth = 0
By default, when you double click on the tag name using the left mouse
button, the cursor will be positioned at the definition of the tag. You
can set the Tlist_Use_SingleClick variable to one to jump to a tag when
you single click on the tag name using the mouse. By default this variable
is set to zero.
??????????????let Tlist_Use_SingleClick = 1
By default, the taglist window will contain text that display the name of
the file, sort order information and the key to press to get help. Also,
empty lines will be used to separate different groups of tags. If you
don't need these information, you can set the Tlist_Compact_Format variable
to one to get a compact display.
??????????????let Tlist_Compact_Format = 1
Extending
You can add support for new languages or modify the support for an already
supported language by setting the following variables in the .vimrc file.
To modify the support for an already supported language, you have to set the
tlist_xxx_ctags_args and tlist_xxx_tag_types variables (replace xxx with the
name of the language).??For example, to list only the classes and functions
defined in a C++ language file, add the following lines to your .vimrc file
??????let tlist_cpp_ctags_args = '--language-force=c++ --c++-types=fc'
??????let tlist_cpp_tag_types = 'class function'
The tlist_xxx_ctags_args setting will be passed as command-line argument to
the exuberant ctags tool. The names set in the tlist_xxx_tag_types variable
must exactly match the tag type names used by the exuberant ctags tool.
Otherwise, you will get error messages when using the taglist plugin. You
can get the tag type names used by exuberant ctags using the command line
??????ctags -f - --fields=K <filename>
To add support for a new language, you have to set the name of the language
in the tlist_file_types variable. For example,
??????let tlist_file_types = 'xxx'
In addition to the above setting, you have to set the tlist_xxx_ctags_args
and the tlist_xxx_tag_types variable as described above.

?
install details
1. Copy the taglist.vim script to the .vim/plugin directory.??Refer
?? to help add-plugin', 'help add-global-plugin' and 'help
?? runtimepath' for more details about Vim plugins.
2. Set the Tlist_Ctags_Cmd variable to point to the exuberant ctags
?? utility path.
3. If you are running a terminal/console version of Vim and the
?? terminal doesn't support changing the window width then set the
?? Tlist_Inc_Winwidth variable to 0.
4. Restart Vim.
5. You can use the ":Tlist" command to open/close the taglist window.
?

http://vimcdoc.sf.net

文章选项: 打印

bsdlinux
(member)
03-01-23 09:43
[精华] Re: Vim 精品插件 1 -- taglist 新 [re: lang2] 

good

文章选项: 打印

jbtzhm
(enthusiast)
03-01-23 16:08
[精华] Re: Vim 精品插件 1 -- taglist 新 [re: lang2] 

好像退出vi窗口才能进Tlist窗口,怎样不关窗口在两个窗口之间切换。

还有taglist.vim在win32系统中能用吗?应该考到什么路径下?


爱~只要一点点冲动就可以!
但了解~却少些默契都不行!

文章选项: 打印

younker
(old hand)
03-01-23 17:01
[精华] Re: Vim 精品插件 1 -- taglist 新 [re: lang2] 

还有个cppcomplete插件,用来自动完成代码的,现在已经3.0版了
www.vim.org


吃得比猪少,干得比牛多。睡得比狗晚,起的比鸡早。

文章选项: 打印

mikewang
(stranger)
03-01-23 17:42
[精华] Re: Vim 精品插件 1 -- taglist 新 [re: younker] 

网址访问不了。

文章选项: 打印

younker
(old hand)
03-01-23 17:48
[精华] Re: Vim 精品插件 1 -- taglist 新 [re: mikewang] 

找个代理吧?
不知道为什么 www.vim.org也封锁。


吃得比猪少,干得比牛多。睡得比狗晚,起的比鸡早。

文章选项: 打印

此话题的页数:1 | 2 | 3 | (显示全部)   打印

前往讨论区

Contact Us LINUXFORUM.NET