Softpanorama

May the source be with you, but remember the KISS principle ;-)
Home Switchboard Unix Administration Red Hat TCP/IP Networks Neoliberalism Toxic Managers
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and  bastardization of classic Unix

Ctags Code Browsing Framework

News See also Recommended Links Recommended Articles

Reference and FAQs

Pltag
tag generator
Editors and Tools Supporting CTAGS
Non Standard Tag File Placement Shtags tag generator sqltag.sh Humor History Etc

Vi/Vim by default read a tag file by the name tags in the current directory and assumes that it contains the navigation map of the source code that is edited. Typically all subroutines are tagged and jump to and back subroutines are the main use of tags. Tag can point to the current file or a different file.

Think about tag file as the set of bookmarks that simplify editing the code. Although such file can be built manually usually a special script is used to produce file automatically. It also can be run from the vi itself.  It is most conviniet to syncronize creation of the tag file with checking the script syntax, for example:

perl -cw $1 
ptags $1 
If you are using vim you can run the tag command from it or automatically before loading the file
  ptags $1
  vim $1

Once vi/vim have read a tag file several command can be used to simplify navigation and code browsing:

Vim online help explains the tags support (use :help tagsearch.txt ). You can also use the help keywords mentioned in this document to read more about a particular command or option. To read more about a particular command or option use,

:help <helpkeyword>

For example: help tag

A tags file is a sorted file that has three tab-separated fields:

The tags file is always sorted by tag name to allow binary search of the tag. That permit using quite large tag files (say, with more then 1K entries) which contain all function and variables definitions on the program or set of programs. Of course you need to ensure that tag file is current and the simplest way to do this is to run the tag generator just before invocation of vim.

If the line ended with a semicolon and then a double-quote (;"), anything following those two characters would be ignored. (The double-quote starts a comment, as it does in .exrc files.)

There are several popular tag generator programs:

Exuberant ctags use an extended tag file format. The first three fields are the same: tag, filename, and search pattern. After those three fields there are several additional fields using exclusively by the program:

Keyword Meaning
kind

The value is a single letter that indicates the lexical type of the tag. It can be f for a function, v for a variable, and so on. Since the default attribute name is kind, a solitary letter can denote the tag's type (e.g., f for a function).

file

For tags that are "static", i.e., local to the file. The value should be the name of the file.

If the value is given as an empty string (just file:), it is understood to be the same as the filename field; this special case was added partly for the sake of compactness, and partly to provide an easy way to handle tags files that aren't in the current directory. The value of the filename field is always relative to the directory in which the tags file itself resides.

function

For local tags. The value is the name of function in which they're defined.

struct

For fields in a struct. The value is the name of the structure.

enum

For values in an enum data type. The value is the name of the enum type.

class

For C++ member functions and variables. The value is the name of the class.

scope

Intended mostly for C++ class member functions. It will usually be private for private members or omitted for public members, so users can restrict tag searches to only public members.

arity

For functions -- the number of arguments.

Extended attributes are placed after a separating ;". Each attribute is separated from the next by a tab character, and consists of two colon-separated subfields. The first subfield is a keyword describing the attribute, the second is the actual value.

Ctags is the most versatile as it supports many languages, but the quality of tagging leaves much to be designed. It is always better to use a custom Perl script derived, say, from ptags.pl.

The simplest usage of ctags is to run it just before editing the file by creating an envelope script or function, for example:

function vvv { 
   ctags $1
   vim $1
}

Ctags tag all functions. That means that you can jump to a function by typing

:tagmy_function If such tag exists the command will move the cursor on first line of my_function()

But the more common and convenient way of using this feature is to jump into the function from a line in file which contains the function name. Just place the cursor before the function name and press CTRL+]. To go back to the calling line press CTRL+t.

Ctags can recursively create the tags file for the entire directory and its subdirectories or for particular list of files (project file)

ctags -R # generate tags for all files in the directory tree
ctags -L flist  # generate tags for the list of file in flist

There is a possibility to set a tags file search order in .gvimrc file

$ vi ~/.gvimrc
" Set the tag file search order
set tags=./tags,tags,~/tags,/home/john/ccplus/tags

This also can be done in Vim session using colon command set

:set tags=./tags,tags,~/tags,/home/john/ccplus/tags

For more information see:


Top Visited
Switchboard
Latest
Past week
Past month

NEWS CONTENTS

Old News ;-)

[Aug 29, 2012] Vim Taglist plugin features

The taglist plugin provides the following features:

[Aug 18, 2009] Ctags With Emacs and Vim - ServerWatch.com

For Vim, you can also try the taglist.vim plugin, which will give you a tag overview side panel. For autocompletion of tag names, try Ctrl-P (this will also autocomplete other words in the file), providing another IDE-type feature.

IDEs do have their uses, but editors can be faster under the fingers and easier to run on slower machines; exuberant-ctags is useful to speed up your coding within your preferred editor.

Blog of Leonid Mamchenkov " Vim for Perl developers

This is my attempt to provide a clear and simple instructions on adopting Vim text editor for programming needs. I am using Perl as the programming language in the examples, but most of this document will apply equally for any other programming language.

Perl Tags generator [83388 sourcecode] tag generation for Perl that uses debugger hooks.

Massconfusion Tim

Project details for Exuberant Ctags

Exuberant Ctags is a multilanguage reimplementation of the Unix ctags program. It generates an index of source code object definitions which is used by a number of editors and tools to instantly locate the definitions. Exuberant Ctags currently supports the following languages: Assembler, ASP, AWK, BETA, C, C++, C#, COBOL, Eiffel, Erlang, Fortran, HTML, Java, Javascript, Lisp, Lua, Make, Pascal, Perl, PHP, PL/SQL, Python, REXX, Ruby, Scheme, Shell (Bourne, Korn, Z), S-Lang, SML (Standard ML), Tcl, Vera, Verilog, Vim, and YACC.

Tip #450 - Working with multiple sessions vim online

The problem I'm trying to solve: I usually need to work on different projects (let us call them: PROJ1 and PROJ2). These are in different directories, have different files.. etc. It would be nice if I can instruct my editor to take me back to the exact session (see :help sessions) for each of these projects - open the required files and buffers, window layout etc...

taglist.vim - Source code browser (supports C-C++, java, perl, python, tcl, sql, php, etc) vim online

taglist.vim : Source code browser (supports C/C++, java, perl, python, tcl, sql, php, etc)

Yegappan Lakshmanan

The "Tag List" plugin is a source code browser plugin for Vim and
provides an overview of the structure of source code files and allows
you to efficiently browse through source code files for different
programming languages. You can visit the taglist plugin home page for
more information:

http://vim-taglist.sourceforge.net

You can subscribe to the taglist mailing list to post your questions
or suggestions for improvement or to report bugs. Visit the following
page for subscribing to the mailing list:

http://groups.yahoo.com/group/taglist/

For more information about using this plugin, after installing the
taglist plugin, use the ":help taglist" command.

install details

1. Download the taglist.zip file and unzip the files to the $HOME/.vim or the
$HOME/vimfiles or the $VIM/vimfiles directory. After this step, you should
have the following two files (the directory structure should be preserved):

plugin/taglist.vim - main taglist plugin file
doc/taglist.txt - documentation (help) file

Refer to the |add-plugin|, |add-global-plugin| and |runtimepath| Vim
help pages for more details about installing Vim plugins.

2. Change to the $HOME/.vim/doc or $HOME/vimfiles/doc or $VIM/vimfiles/doc
directory, start Vim and run the ":helptags ." command to process the
taglist help file. Without this step, you cannot jump to the taglist help
topics.

3. If the exuberant ctags utility is not present in your PATH, then set the
Tlist_Ctags_Cmd variable to point to the location of the exuberant ctags
utility (not to the directory) in the .vimrc file.
4. 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 in the .vimrc file.
5. Restart Vim.
6. You can now use the ":TlistToggle" command to open/close the taglist
window. You can use the ":help taglist" command to get more information
about using the taglist plugin.

Tip #94 - Questions & Answers about using tags with Vim vim online

This document gives you a idea about the various facilities available in Vim for using a tags file to browse through program source files. You can read the Vim online help, which explains in detail the tags support, using :help tagsearch.txt. You can also use the help keywords mentioned in this document to read more about a particular command or option. To read more about a particular command or option use,

:help <helpkeyword>

in Vim.

1. How do I create a tags file?

You can create a tags file either using the ctags utility or using a custom script or utility.

Help keyword(s): tag

2. Where can I download the tools to generate the tags file?

There are several utilities available to generate the tags file. Depending on the programming language, you can use any one of them.

1. Exuberant ctags generates tags for the following programming language files:

Assembler, AWK, ASP, BETA, Bourne/Korn/Zsh Shell, C, C++, COBOL,
Eiffel, Fortran, Java, Lisp, Make, Pascal, Perl, PHP, Python,
REXX, Ruby, S-Lang, Scheme, Tcl, and Vim.

You can download exuberant ctags from
http://ctags.sourceforge.net/

2. On Unix, you can use the /usr/bin/ctags utility. This utility is present in most of the Unix installations.

3. You can use jtags for generating tags file for java programs.
You can download jtags from: http://www.fleiner.com/jtags/

4. You can download scripts from the following links for generating tags file for verilog files:

http://www.probo.com/vtags.htm
http://www.cs.albany.edu/~mosh/Perl/veri-tags
http://www.verilog.net/vrtags.txt

5. You can download Hdrtag from the following linke:

http://www.erols.com/astronaut/vim/index.html#Tags

This utility generates tags file for the following programming languages: assembly, c/c++, header files, lex, yacc,LaTeX, vim, and Maple V.

6. You can also use the following scripts which are part of the Vim runtime files:

pltags.pl - Create tags file for perl code
tcltags - Create tags file for TCL code
shtags.pl - Create tags file for shell script

Help keyword(s): ctags

3. How do I generate a tags file using ctags?

You can generate a tags file for all the C files in the current directory using the following command:

$ ctags *.c

You can generate tags file for all the files in the current directory and all the sub-directories using (this applies only to exuberant ctags):

$ ctags -R .

You can generate tags file for all the files listed in a text file named flist using (this applies only to exuberant ctags)

$ ctags -L flist

4. How do I configure Vim to locate a tags file?

You can set the 'tags' option in Vim to specify a particular tags file.

set tags=/my/dir/tags

Help keyword(s): 'tags', tags-option

5. How do I configure Vim to use multiple tags files?

The 'tags' option can specify more than one tags file. The tag
filenames are separated using either comma or spaces.

set tags=/my/dir1/tags, /my/dir2/tags

6. How do I configure Vim to locate a tags file in a directory tree?

You can set the 'tags' option to make Vim search for the tags file in a
directory tree. For example, if the 'tags' option is set like
this:

set tags=tags;/

Vim will search for the file named 'tags', starting with the
current directory and then going to the parent directory and then
recursively to the directory one level above, till it either
locates the 'tags' file or reaches the root '/' directory.

Help keyword(s): file-searching

7. How do I jump to a tag?

There are several ways to jump to a tag location.
1. You can use the 'tag' ex command. For example,

:tag <tagname>

will jump to the tag named <tagname>.
2. You can position the cursor over a tag name and then press
Ctrl-].
3. You can visually select a text and then press Ctrl-] to
jump to the tag matching the selected text.
4. You can click on the tag name using the left mouse button,
while pressing the <Ctrl> key.
5. You can press the g key and then click on the tag name
using the left mouse button.
6. You can use the 'stag' ex command, to open the tag in a new
window. For example,

:stag func1

will open the func1 definition in a new window.
7. You can position the cursor over a tag name and then press
Ctrl-W ]. This will open the tag location in a new window.

Help keyword(s): :tag, Ctrl-], v_CTRL_], <C-LeftMouse>,
g<LeftMouse>, :stag, Ctrl-W_]

8. How do I come back from a tag jump?

There are several ways to come back to the old location from a tag
jump.
1. You can use the 'pop' ex command.
2. You can press Ctrl-t.
3. You can click the right mouse button, while pressing the
<Ctrl> key.
4. You can press the g key and then click the right mouse
button.

Help keyword(s): :pop, Ctrl-T, <C-RightMouse>, g<RightMouse>

9. How do I jump again to a previously jumped tag location?

You can use the 'tag' ex command to jump to a previously jumped tag
location, which is stored in the tag stack.

Help keyword(s): tag

10. How do I list the contents of the tag stack?

Vim remembers the location from which you jumped to a tag in the
tag stack. You can list the current tag stack using the 'tags' ex
command.

Help keyword(s): :tags, tagstack

11. How do I jump to a particular tag match, if there are multiple
matching tags?

In some situations, there can be more than one match for a tag.
For example, a C function or definition may be present in more
than one file in a source tree. There are several ways to jump to
a specific tag from a list of matching tags.

1. You can use the 'tselect' ex command to list all the tag
matches. For example,

:tselect func1

will list all the locations where func1 is defined. You can
then enter the number of a tag match to jump to that
location.
2. You can position the cursor over the tag name and press g]
to get a list of matching tags.
3. You can visually select a text and press g] to get a list
of matching tags.
4. You can use the 'stselect' ex command. This will open the
selected tag from the tag list in a new window.
5. You can position the cursor over the tag name and press
Ctrl-W g] to do a :stselect.

Help keyword(s): tag-matchlist, :tselect, g], v_g], :stselect,
Ctrl-W_g]

12. I want to jump to a tag, if there is only one matching tag,
otherwise a list of matching tags should be displayed. How do I
do this?

There are several ways to make Vim to jump to a tag directly, if
there is only one tag match, otherwise present a list of tag
matches.

1. You can use the 'tjump' ex command. For example,

:tjump func1

will jump to the definition func1, if it is defined only
once. If func1 is defined multiple times, a list of
matching tags will be presented.
2. You can position the cursor over the tag and press g
Ctrl-].
3. You can visually select a text and press g Ctrl-] to jump
or list the matching tags.
4. You can use the 'stjump' ex command. This will open the
matching or selected tag from the tag list in a new window.
5. You can press Ctrl-W g Ctrl-] to do a :stjump.

Help keyword(s): :tjump, g_Ctrl-], v_g_CTRL-], :stjump,
Ctrl-W_g_Ctrl-]

13. How do browse through a list of multiple tag matches?

If there are multiple tag matches, you can browse through all of
them using several of the Vim ex commands.

1. To go to the first tag in the list, use the 'tfirst' or
'trewind' ex command.
2. To go to the last tag in the list, use the 'tlast' ex command.
3. To go to the next matching tag in the list, use the 'tnext' ex
command.
4. To go to the previous matching tag in the list, use the
'tprevious' or 'tNext' ex command.

Help keyword(s): :tfirst, :trewind, :tlast, :tnext, :tprevious,
:tNext

14. How do I preview a tag?

You can use the preview window to preview a tag, without leaving
the original window. There are several ways to preview a tag:

1. You can use the 'ptag' ex command to open a tag in the
preview window.
2. You can position the cursor on a tag name and press Ctrl-W
} to open the tag in the preview window.
3. You can use the 'ptselect' ex command to do the equivalent
of the 'tselect' ex command in the preview window.
4. You can use the 'ptjump' ex command to do the equivalent of
the 'tjump' ex command in the preview window.
5. You can position the cursor on the tag and press Ctrl-W g}
to do a :ptjump on the tag.

Help keyword(s): :preview-window, :ptag, Ctrl-W_}, :ptselect,
:ptjump, Ctrl-W_g}

15. How do I browse through the tag list in a preview window?

If there are multiple tag matches, you can browse through all of
them in the preview window using several of the Vim ex commands.

1. To go to the first tag in the list, use the 'ptfirst' or
'ptrewind' ex command.
2. To go to the last tag in the list, use the 'ptlast' ex command.
3. To go to the next matching tag in the list, use the 'ptnext' ex
command.
4. To go to the previous matching tag in the list, use the
'ptprevious' or 'ptNext' ex command.

Help keyword(s): :ptfirst, :ptrewind, :ptlast, :ptnext,
:ptprevious, :ptNext

16. How do I start Vim to start editing a file at a given tag match?

While starting Vim, you can use the command line option '-t' to
supply a tag name. Vim will directly jump to the supplied tag
location.

Help keyword(s): -t

17. How do I list all the tags matching a search pattern?

There are several ways to go through a list of all tags matching a
pattern.

1. You can list all the tags matching a particular regular
expression pattern by prepending the tag name with the '/'
search character. For example,

:tag /<pattern>
:stag /<pattern>
:ptag /<pattern>
:tselect /<pattern>
:tjump /<pattern>
:ptselect /<pattern>
:ptjump /<pattern>

2. If you have the 'wildmenu' option set, then you can press
the <Tab> key to display a list of all the matching tags
in the status bar. You can use the arrow keys to move
between the tags and then use the <Enter> key to select a
tag.

3. If you don't have the 'wildmenu' option set, you can still
use the <Tab> key to browse through the list of matching
tags.

Help keyword(s): tag-regexp, wildmenu

18. What options are available to control how Vim handles the tags
file?

You can use the following options to control the handling of tags file by Vim:

1. 'tagrelative' - Controls how the file names in the tags file are treated. When on, the filenames are
relative to the directory where the tags file is present.

2. 'taglength' - Controls the number of significant characters used for recognizing a tag.

3. 'tagbsearch' - Controls the method used to search the tags file
for a tag. If this option is on, binary search
is used to search the tags file. Otherwise,
linear search is used.

4. 'tagstack' - Controls how the tag stack is used.

Help keyword(s): 'tagrelative', 'taglength', 'tagbsearch',
'tagstack'

19. Is it possible to highlight all the tags in the current file?

Yes. Read the Vim online help on "tag-highlight".

20. Is it possible to create a menu with all the tags in the current
file?

Yes. It is possible to create a menu with all the tags in the
current file using a Vim script. Download the TagsMenu.vim script
from the following link:

http://members.home.net/jayglanville/tagsmenu/TagsMenu.html

21. Is there a workaround to make the Ctrl-] key not to be treated as
the telnet escape character?

The default escape characters for telnet in Unix systems is
Ctrl-]. While using Vim in a telnet session, if you use Ctrl-] to
jump to a tag, you will get the telnet prompt. There are two ways
to avoid this problem:

1. Map the telnet escape character to some other character using
the "-e <escape character>" telnet command line option

2. Disable the telnet escape character using the "-E" telnet
command line option.

Help keyword(s): telnet-CTRL-]

Massconfusion Tim

Perl Tagging

This information was not the easiest to dig up. But if you want more information do a :help perl_info and some information should be there with additional links on where you can dig up more.

In general there are two things to do:

find /usr/lib/perl5 -name *.pm -type f -exec ptags.pl -m -t path_to_tags_file {} \;

Limitations of Perl tagging (at least with the script here): Tagging uses the first match found in the tagging file. As a result only unique function names can be found (usually not a problem) but with the advent of Perl OO common functions like "new" do not work well with tagging. Also explicit object referencing via :: also does not work. However most function names are unique so this often is not a problem. It certainly makes life easier when going through a lot of perl files!

Exuberant ctags and Vim

Exuberant ctags is simply great. And VIM gets a nice plugin that uses it.

There is a new VIM plugin in town. The "Tag List" plugin can be used to efficiently browse through your source files.

I downloaded it, played with it and liked it. The underlying tagger is exuberant Ctags. I started exploring other editors mainly because I didn't find a tagger for other languages. This Ctags support all languages I use currently.

I think I switch to other editors once in a while for these:

ctags.vim - Display function name in the title bar. vim online

This script uses exuberant ctags to build the list of tags for the current file. CursorHold event is then used to update titlestring.

Upon sourcing an autocommand is created with event type CursorHold. It updates the title string using the function GetTagName. Another autocommand of type BufEnter is created to generate tags for *.c, *.cpp and *.h files.

Function GenerateTags builds an array of tag names.

Function GetTagName takes line number argument and returns the tag name. install details Before sourcing the script do:
let g:ctags_path='/path/to/ctags'
let g:ctags_args='-I __declspec+' (or whatever other additional arguments you want to pass to ctags)

Linux Online - The Linux Tips HOWTO Short Tips

I do a lot of C programming in my spare time, and I've taken the time to rig vi to be C friendly. Here's my .exrc:
set autoindent
set shiftwidth=4
set backspace=2
set ruler

What does this do? autoindent causes vi to automatically indent each line following the first one indented, shiftwidth sets the distance of ^T to 4 spaces, backspace sets the backspace mode, and ruler makes it display the line number. Remember, to go to a specific line number, say 20, use:

vi +20 myfile.c

2.18 Using ctags to ease programming.

Most hackers already have ctags on their computers, but don't use it. It can be very handy for editing specific functions. Suppose you have a function, in one of many source files in a directory for a program you're writing, and you want to edit this function for updates. We'll call this function foo(). You don't where it is in the source file, either. This is where ctags comes in handy. When run, ctags produces a file named tags in the current dir, which is a listing of all the functions, which files they're in and where they are in said files. The tags file looks like this:

ActiveIconManager       iconmgr.c       /^void ActiveIconManager(active)$/
AddDefaultBindings      add_window.c    /^AddDefaultBindings ()$/
AddEndResize    resize.c        /^AddEndResize(tmp_win)$/
AddFuncButton   menus.c /^Bool AddFuncButton (num, cont, mods, func, menu, item)$/
AddFuncKey      menus.c /^Bool AddFuncKey (name, cont, mods, func, menu, win_name, action)$/
AddIconManager  iconmgr.c       /^WList *AddIconManager(tmp_win)$/
AddIconRegion   icons.c /^AddIconRegion(geom, grav1, grav2, stepx, stepy)$/
AddStartResize  resize.c        /^AddStartResize(tmp_win, x, y, w, h)$/
AddToClientsList        workmgr.c       /^void AddToClientsList (workspace, client)$/
AddToList       list.c  /^AddToList(list_head, name, ptr)$/

To edit, say AddEndResize() in vim, run:

vim -t AddEndResize
This will bring the appropriate file up in the editor, with the cursor located at the beginning of the function.

[Jan 2, 2005] C-editing-with-VIM-HOWTO. See also Ctags code browsing framework

3.1. ctags

A Tag is a sort of placeholder. Tags are very useful in understanding and
editing C. Tags are a set of book-marks to each function in a C file. Tags
are very useful in jumping to the definition of a function from where it is
called and then jumping back.

Take the following example.


Figure 6. Tags Example

[tags]

Lets say that you are editing the function foo() and you come across the
function bar(). Now, to see what bar() does, one makes uses of Tags. One can
jump to the definition of bar() and then jump back later. If need be, one can
jump to another function called within bar() and back.

To use Tags one must first run the program ctags on all the source files.
This creates a file called tags. This file contains pointers to all the
function definitions and is used by VIM to take you to the function
definition.

The actual keystrokes for jumping to and fro are CTRL-] and CTRL-T. By
hitting CTRL-] in foo() at the place where bar() is called, takes the cursor
to the beginning of bar(). One can jump back from bar() to foo() by just
hitting CTRL-T.

ctags are called by
$ ctags options file(s)


To make a tags file from all the *.c files in the current directory all one
needs to say is
$ ctags *.c


In case of a source tree which contains C files in different sub directories,
one can call ctags in the root directory of the source tree with the -R
option and a tags file containing Tags to all functions in the source tree
will be created. For Example.
$ ctags -R *.c


There are many other options to use with ctags. These options are explained
in the man file for ctags.
-----------------------------------------------------------------------------

3.2. marks

Marks are place-holders like Tags. However, marks can be set at any point in
a file and is not limited to only functions, enums etc.. Plus marks have be
set manually by the user.

By setting a mark there is no visible indication of the same. A mark is just
a position in a file which is remembered by VIM. Consider the following code


Figure 7. The marks example

[marks]

Suppose you are editing the line x++; and you want to come back to that line
after editing some other line. You can set a mark on that line with the
keystroke m' and come back to the same line later by hitting ''.

VIM allows you to set more than one mark. These marks are stored in registers
a-z, A-Z and 1-0. To set a mark and store the same in a register say j, all
one has to hit is mj. To go back to the mark one has to hit 'j.

Multiple marks are really useful in going back and fro within a piece of
code. Taking the same example, one might want one mark at x++; and another at
y=x; and jump between them or to any other place and then jump back.

Marks can span across files. To use such marks one has to use upper-case
registers i.e. A-Z. Lower-case registers are used only within files and do
not span files. That's to say, if you were to set a mark in a file foo.c in
register "a" and then move to another file and hit 'a, the cursor will not
jump back to the previous location. If you want a mark which will take you to
a different file then you will need to use an upper-case register. For
example, use mA instead of ma. I'll talk about editing multiple files in a
later section.
-----------------------------------------------------------------------------

3.3. gd keystroke

Consider the following piece of code.


Figure 8. The third example

[gd]

For some reason you've forgotten what y and z are and want to go to their
declaration double quick. One way of doing this is by searching backwards for
y or z. VIM offers a simpler and quicker solution. The gd keystroke stands
for Goto Declaration. With the cursor on "y" if you hit gd the cursor will
take you to the declaration :- struct Y y;.

A similar keystroke is gD. This takes you to the global declaration of the
variable under the cursor. So if one want to go to the declaration of x, then
all one needs to do is hit gD and the cursor will move to the declaration of
x.

Tip #94 - Questions & Answers about using tags with Vim vim online

When -R option is not available (on Solaris), use find to generate the list of files and give them as input to ctags using -L option.

Re Help using exhuberant ctags as a parser

From: Shigio Yamaguchi
Subject: Re: Help using exhuberant ctags as a parser
Date: Fri, 25 May 2001 01:52:38 +0900

Hello,
> I would like to use global to generate an HTML site of some COBOL code
> in my organization. My plans were to use the exhuberant ctags as the
> parser since it will parse COBOL code and then use htags to generate the
> HTML files. I've followed the suggestions in the tutorial for plugging
> in another parser, but it doesn't seem to be working. Here's output
> from my ksh session. (Note, I'm using a local copy of ctags that I
> compiled myself after downloading from sourceforge).
> 
> 
> 
> % cp ~/bin/ctags ~/bin/ctags-exuberant
> % GTAGSLABEL=ctags-exuberant; export GTAGSLABEL
> % gtags
> % ls -l G* | awk '{printf( "%d\t%s\n", $5, $9 )}'
> 16384 GPATH
> 0 GRTAGS
> 0 GSYMS
> 0 GTAGS
> %
> 
> The only file with anything in it is the GPATH file. I can get ctags to
> work using "ctags *.cob" with no problems, and it creates a very largs
> tags file.

Probably, you didn't add 'cob' suffix to variable 'suffixes' in global.conf.
Without it, gtags cannot pick up cobol's source files.

Please add 'cob' to suffixes.

ctags-emacs|ctags based on etags|GNU Emacs ctags:\
        :tc=common:\
        :suffixes=el,s,a,sa,asm,C,H,cpp,cxx,hxx,cc,c,h,y,cob:\  <= add 'cob'
        :extractmethod:\
        :GTAGS=/usr/local/bin/ctags-emacs -x -d -T -w %s:

> Whenever I run the htags program, it creates a bunch of html files that
> don't show anything at all. No source code, no tags, no anything.

To apply htags to other languages, you must modify the parser (ctags) so that
it can treat function (procedure) references.
When you have done it, you can write global.conf like this:

        :GTAGS=/usr/local/bin/ctags-emacs -x -d -T -w %s:\
        :GRTAGS=/usr/local/bin/ctags-emacs -r -x -d -T -w %s:
                                           ~~
                                        new option: locate function references

By the way, I regret to say that it is difficult for htags to treat other
language without modification. For example, htags cannot understand cobol
style comment. Currently, I don't know what will be needed.

If you make 'Htags for COBOL', please let me know.
--
Shigio Yamaguchi - Tama Communications Corporation
Mail: [email protected], (Spare mail: [email protected])

What's the proper way to use ctags

David Scheidt dmschei at attglobal.net
Wed Dec 8 22:52:17 PST 2004
> > Let say I want to quickly browse through all the source files in a > given > directory. What I tried was I ran ctags -R source_dir, which builds a > tag file for the entire source. When I start vim in that directory and > view files in the sub directories, tag works just fine. But when I go > into other directory(outside of vim), since there is no tag file there, > I can't use the tag feature anymore. > > I could ran ctag in all sub directories, but then I won't be able to > search for functions that are define outside of the sub directory. So > what's the proper way to use ctag? > 
You need to tell vim where your tag files are.

:set tags=./tags,/path/to/your/tags 
(note the lack of a space character there!)

I think the default is just ./tags.  Or perhaps it's "tags,./tags".  I 
don't remember.  Read the vim help files on tags

:help tags 

Regards,

David 

FORMAT

A tags file that is generated in the new format should still be usable by Vi.

This makes it possible to distribute tags files that are usable by all versions and descendants of Vi.

This restricts the format to what Vi can handle. The format is:

1. The tags file is a list of lines, each line in the format:

{tagname}<Tab>{tagfile}<Tab>{tagaddress}

{tagname} Any identifier, not containing white space..
<Tab> Exactly one TAB character (although many versions of Vi can
handle any amount of white space).
{tagfile} The name of the file where {tagname} is defined, relative to
the current directory (or location of the tags file?).
{tagaddress} Any Ex command. When executed, it behaves like 'magic' was
not set.

2. The tags file is sorted on {tagname}. This allows for a binary search in
the file.

3. Duplicate tags are allowed, but which one is actually used is
unpredictable (because of the binary search).

The best way to add extra text to the line for the new functionality, without
breaking it for Vi, is to put a comment in the {tagaddress}. This gives the
freedom to use any text, and should work in any traditional Vi implementation.

For example, when the old tags file contains:

main main.c /^main(argc, argv)$/
DEBUG defines.c 89

The new lines can be:

main main.c /^main(argc, argv)$/;"any additional text
DEBUG defines.c 89;"any additional text

Note that the ';' is required to put the cursor in the right line, and then
the '"' is recognized as the start of a comment.

For Posix compliant Vi versions this will NOT work, since only a line number
or a search command is recognized. I hope Posix can be adjusted. Nvi suffers
from this.

(1) What are some tips for using ctags effectively with a large codebase - Quora

On some Googling, here is what I have. This is assuming that vim is your editor of choice.
First download ctags. On Ubuntu(Debian) it would be:sudo apt-get install exuberant-ctags

After this, install the taglist.vim plugin.
http://vim.sourceforge.net/scrip...
Now you need to configure taglist.vim, this can be done like this:let Tlist_Ctags_Cmd = "/usr/bin/ctags"
let Tlist_WinWidth = 50
map <F4> :TlistToggle<cr>

Pressing F4 toggles the taglist window on and off.
Search and destroy using tags
Have one mapping in vimrc, like:map <F8> :!/usr/bin/ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>

This builds tags libs for the current working directory.
Once you have build tags, you can browse them using builtin functions. Here are some examples:

  • :tag getUser => Jump to getUser method
  • :tn (or tnext) => go to next search result
  • :tp (or tprev) => to to previous search result
  • :ts (or tselect) => List the current tags
  • => Go back to last tag location
  • +Left click => Go to definition of a method

If you want full power out of this:

Recommended Links

Google matched content

Softpanorama Recommended

Top articles

Sites

Ctags

Language specific advice

Editors and Tools that support CTAGS

Vi-style editors

  • Other editors

  • Tools

    Reference and FAQs

    [Chapter 8] vi Clones Feature SummaryThe New tags Format

    Traditionally, a tags file has three tab-separated fields: the tag name (typically an identifier), the source file containing the tag, and an indication of where to find the identifier. This indication is either a simple line number, or a nomagic search pattern enclosed either in slashes or question marks. Furthermore, the tags file is always sorted.

    This is the format generated by the UNIX ctags program. In fact, many versions of vi allowed any command in the search pattern field (a rather gaping security hole). Furthermore, due to an undocumented implementation quirk, if the line ended with a semicolon and then a double-quote (;"), anything following those two characters would be ignored. (The double-quote starts a comment, as it does in .exrc files.)

    The new format is backwards-compatible with the traditional one. The first three fields are the same: tag, filename, and search pattern. Exuberant ctags only generates search patterns, not arbitrary commands. Extended attributes are placed after a separating ;". Each attribute is separated from the next by a tab character, and consists of two colon-separated subfields. The first subfield is a keyword describing the attribute, the second is the actual value. Table 8.2 lists the supported keywords.

    Table 8.2: Extended ctags Keywords
    Keyword Meaning
    kind

    The value is a single letter that indicates the lexical type of the tag. It can be f for a function, v for a variable, and so on. Since the default attribute name is kind, a solitary letter can denote the tag's type (e.g., f for a function).

    file

    For tags that are "static", i.e., local to the file. The value should be the name of the file.

    If the value is given as an empty string (just file:), it is understood to be the same as the filename field; this special case was added partly for the sake of compactness, and partly to provide an easy way to handle tags files that aren't in the current directory. The value of the filename field is always relative to the directory in which the tags file itself resides.

    function

    For local tags. The value is the name of function in which they're defined.

    struct

    For fields in a struct. The value is the name of the structure.

    enum

    For values in an enum data type. The value is the name of the enum type.

    class

    For C++ member functions and variables. The value is the name of the class.

    scope

    Intended mostly for C++ class member functions. It will usually be private for private members or omitted for public members, so users can restrict tag searches to only public members.

    arity

    For functions. The number of arguments.

    If the field does not contain a colon, it is assumed to be of type kind. Here are some examples:

    ARRAYMAXED      awk.h    427;"   d
    AVG_CHAIN_MAX   array.c   38;"   d     file:
    array.c         array.c    1;"   F

    ARRAYMAXED is a C #define macro defined in awk.h. AVG_CHAIN_MAX is also a C macro but it is used only in array.c. The third line is a bit different: it is a tag for the actual source file! This is generated with the -i F option to Exuberant ctags, and allows you to give the command :tag array.c. More usefully, you can put the cursor over a filename and use the ^] command to go to that file.

    Within the value part of each attribute, the characters backslash, tab, carriage return and newline should be encoded as \\, \t, \r, and \n, respectively.

    Extended tags files may have some number of initial tags that begin with !_TAG_. These tags usually sort to the front of the file, and are useful for identifying which program created the file. Here is what Exuberant ctags generates:

    !_TAG_FILE_FORMAT      2                /extended format; ..../
    !_TAG_FILE_SORTED      1                /0=unsorted, 1=sorted/
    !_TAG_PROGRAM_AUTHOR   Darren Hiebert   /[email protected]/
    !_TAG_PROGRAM_NAME     Exuberant Ctags  //
    !_TAG_PROGRAM_URL      http://home.hiwaay.net/~darren/ctags   /.../
    !_TAG_PROGRAM_VERSION  2.0.3            /with C++ support/

    Editors may take advantage of these special tags to implement special features. For example, vim pays attention to the !_TAG_FILE_SORTED tag and will use a binary search to search the tags file instead of a linear search if the file is indeed sorted.

    If you use tags files, we recommend that you get and install Exuberant ctags.

    Non Standard Tag File Placement

    You can set the 'tags' option in Vim to specify a non-standard tags file placement:

    set tags=/my/dir/tags

    The 'tags' option can specify more than one tags file. The tag filenames are separated using either comma or spaces.

    set tags=/my/dir1/tags, /my/dir2/tags

    in Vim 6.0 and above you can also set the 'tags' option to make Vim search for the tags file in a
    directory tree. For example, if the 'tags' option is set like this:

    set tags=tags;/

    Vim will search for the file named 'tags', starting with the current directory and then going to the parent directory and then recursively to the directory one level above, till it either locates the 'tags' file or reaches the root '/' directory.

    Tag Stacks

    [Chapter 8] vi Clones Feature Summary

    The :tag ex command and the ^] vi mode command provide a limited means of finding identifiers, based on the information provided in a tags file. Each of the clones extends this ability by maintaining a stack of tag locations. Each time you issue the :tag ex command, or use the ^] vi mode command, the editor saves the current location before searching for the specified tag. You may then return to a saved location using (usually) the ^T command or an ex command.

    Solaris vi tag stacking and an example are presented below. The way each clone handles tag stacking is described in each editor's respective chapter.

    8.5.3.1 Solaris vi

    Surprisingly enough, the Solaris 2.6 version of vi supports tag stacking. Perhaps not so surprisingly, this feature is completely undocumented in the Solaris ex(1) and vi(1) manual pages. For completeness, we summarize Solaris vi tag stacking in Table 8.3, Table 8.4, and Table 8.5. Tag stacking in Solaris vi is quite simple.[6]

    [6] This information was discovered based on experimentation. YMMV (your mileage may vary).

    Table 8.3: Solaris vi Tag Commands
    Command Function
    ta[g][!] tagstring

    Edit the file containing tagstring as defined in the tags file. The ! forces vi to switch to the new file if the current buffer has been modified but not saved.

    po[p][!]

    Pop the tag stack by one element.

    Table 8.4: Solaris vi Command Mode Tag Commands
    Command Function
    ^]

    Look up the location of the identifier under the cursor in the tags file, and move to that location. If tag stacking is enabled, the current location is automatically pushed onto the tag stack.

    ^T

    Return to the previous location in the tag stack, i.e., pop off one element.

    Table 8.5: Solaris vi Options for Tag Management
    Option Function
    taglength, tl

    Controls the number of significant characters in a tag that is to be looked up. The default value of zero indicates that all characters are significant.

    tags, tagpath

    The value is a list of filenames in which to look for tags. The default value is "tags /usr/lib/tags".

    tagstack

    When set to true, vi stacks each location on the tag stack. Use :set notagstack to disable tag stacking.

    To give you a feel for using tag stacks, we present a short example, using Exuberant ctags and vim.

    Suppose you are working with a program that uses the GNU getopt_long function, and that you need to understand more about it.

    GNU getopt consists of three files, getopt.h, getopt.c, and getopt1.c.

    First, you create the tags file, then you start by editing the main program, found in main.c:

    $ ctags *.[ch]
    $ ls
    Makefile   getopt.c   getopt.h   getopt1.c   main.c   tags
    $ vim main.c
    Keystrokes Results
    /getopt
    Figure 8.0

    Edit main.c and move to the call to getopt_long.

    ^]
    Figure 8.0

    Do a tag lookup on getopt_long. vim moves to getopt1.c, placing the cursor on the definition of getopt_long.

    It turns out that getopt_long is a "wrapper" function for _getopt_internal. You place the cursor on _getopt_internal and do another tag search.

    Keystrokes Results
    8jf_ ^]
    Figure 8.0

    You have now moved to getopt.c. To find out more about struct option, move the cursor to option and do another tag search.

    5jfo; ^]
    Figure 8.0

    The editor moves to the definition of struct option in getopt.h. You may now look over the comments explaining how it's used.

    :tags
    Figure 8.0

    The :tags command in vim displays the tag stack.

    Typing ^T three times would move you back to main.c, where you started. The tag facilities make it easy to move around as you edit source code.

    Vim Color Editor HOW-TO (Vi Improved with syntax color highlighting)

    Vi companions

    Vim documentation tagsrch

    Frequently asked questions about the Taglist Vim plugin The taglist plugin uses the system() function to invoke the exuberant ctags utility. You need to rebuild Vim after enabling the support for the system ...

    Tip #94 - Questions & Answers about using tags with Vim vim online

    Using tags file with Vim
    ------------------------
    This document gives you a idea about the various facilities available
    in Vim for using a tags file to browse through program source files.
    You can read the Vim online help, which explains in detail the tags
    support, using :help tagsearch.txt. You can also use the help
    keywords mentioned in this document to read more about a particular
    command or option. To read more about a particular command or option
    use, :help <helpkeyword> in Vim.

    1. How do I create a tags file?

    You can create a tags file either using the ctags utility or using
    a custom script or utility.

    Help keyword(s): tag

    2. Where can I download the tools to generate the tags file?

    There are several utilities available to generate the tags file.
    Depending on the programming language, you can use any one of them.

    1. Exuberant ctags generates tags for the following programming
    language files:

    Assembler, AWK, ASP, BETA, Bourne/Korn/Zsh Shell, C, C++, COBOL,
    Eiffel, Fortran, Java, Lisp, Make, Pascal, Perl, PHP, Python,
    REXX, Ruby, S-Lang, Scheme, Tcl, and Vim.

    You can download exuberant ctags from
    http://ctags.sourceforge.net/

    2. On Unix, you can use the /usr/bin/ctags utility. This utility
    is present in most of the Unix installations.

    3. You can use jtags for generating tags file for java programs.
    You can download jtags from: http://www.fleiner.com/jtags/

    4. You can use ptags for generating tags file for perl programs.
    You can download ptags from:
    http://www.eleves.ens.fr:8080/home/nthiery/Tags/

    5. You can download scripts from the following links for
    generating tags file for verilog files:

    http://www.probo.com/vtags.htm
    http://www.cs.albany.edu/~mosh/Perl/veri-tags
    http://www.verilog.net/vrtags.txt

    6. You can download Hdrtag from the following linke:

    http://www.erols.com/astronaut/vim/index.html#Tags

    This utility generates tags file for the following programming
    languages: assembly, c/c++, header files, lex, yacc,LaTeX, vim,
    and Maple V.

    7. You can also use the following scripts which are part of the Vim
    runtime files:

    pltags.pl - Create tags file for perl code
    tcltags - Create tags file for TCL code
    shtags.pl - Create tags file for shell script

    Help keyword(s): ctags

    3. How do I generate a tags file using ctags?

    You can generate a tags file for all the C files in the current
    directory using the following command:

    $ ctags *.c

    You can generate tags file for all the files in the current
    directory and all the sub-directories using (this applies only to
    exuberant ctags):

    $ ctags -R .

    You can generate tags file for all the files listed in a text file
    named flist using (this applies only to exuberant ctags)

    $ ctags -L flist

    4. How do I configure Vim to locate a tags file?

    You can set the 'tags' option in Vim to specify a particular tags
    file.

    set tags=/my/dir/tags

    Help keyword(s): 'tags', tags-option

    5. How do I configure Vim to use multiple tags files?

    The 'tags' option can specify more than one tags file. The tag
    filenames are separated using either comma or spaces.

    set tags=/my/dir1/tags, /my/dir2/tags

    6. How do I configure Vim to locate a tags file in a directory tree?

    Note that the following will work only in Vim 6.0 and above. You
    can set the 'tags' option to make Vim search for the tags file in a
    directory tree. For example, if the 'tags' option is set like
    this:

    set tags=tags;/

    Vim will search for the file named 'tags', starting with the
    current directory and then going to the parent directory and then
    recursively to the directory one level above, till it either
    locates the 'tags' file or reaches the root '/' directory.

    Help keyword(s): file-searching

    7. How do I jump to a tag?

    There are several ways to jump to a tag location.
    1. You can use the 'tag' ex command. For example,

    :tag <tagname>

    will jump to the tag named <tagname>.
    2. You can position the cursor over a tag name and then press
    Ctrl-].
    3. You can visually select a text and then press Ctrl-] to
    jump to the tag matching the selected text.
    4. You can click on the tag name using the left mouse button,
    while pressing the <Ctrl> key.
    5. You can press the g key and then click on the tag name
    using the left mouse button.
    6. You can use the 'stag' ex command, to open the tag in a new
    window. For example,

    :stag func1

    will open the func1 definition in a new window.
    7. You can position the cursor over a tag name and then press
    Ctrl-W ]. This will open the tag location in a new window.

    Help keyword(s): :tag, Ctrl-], v_CTRL_], <C-LeftMouse>,
    g<LeftMouse>, :stag, Ctrl-W_]

    8. How do I come back from a tag jump?

    There are several ways to come back to the old location from a tag
    jump.
    1. You can use the 'pop' ex command.
    2. You can press Ctrl-t.
    3. You can click the right mouse button, while pressing the
    <Ctrl> key.
    4. You can press the g key and then click the right mouse
    button.

    Help keyword(s): :pop, Ctrl-T, <C-RightMouse>, g<RightMouse>

    9. How do I jump again to a previously jumped tag location?

    You can use the 'tag' ex command to jump to a previously jumped tag
    location, which is stored in the tag stack.

    Help keyword(s): tag

    10. How do I list the contents of the tag stack?

    Vim remembers the location from which you jumped to a tag in the
    tag stack. You can list the current tag stack using the 'tags' ex
    command.

    Help keyword(s): :tags, tagstack

    11. How do I jump to a particular tag match, if there are multiple
    matching tags?

    In some situations, there can be more than one match for a tag.
    For example, a C function or definition may be present in more
    than one file in a source tree. There are several ways to jump to
    a specific tag from a list of matching tags.

    1. You can use the 'tselect' ex command to list all the tag
    matches. For example,

    :tselect func1

    will list all the locations where func1 is defined. You can
    then enter the number of a tag match to jump to that
    location.
    2. You can position the cursor over the tag name and press g]
    to get a list of matching tags.
    3. You can visually select a text and press g] to get a list
    of matching tags.
    4. You can use the 'stselect' ex command. This will open the
    selected tag from the tag list in a new window.
    5. You can position the cursor over the tag name and press
    Ctrl-W g] to do a :stselect.

    Help keyword(s): tag-matchlist, :tselect, g], v_g], :stselect,
    Ctrl-W_g]

    12. I want to jump to a tag, if there is only one matching tag,
    otherwise a list of matching tags should be displayed. How do I
    do this?

    There are several ways to make Vim to jump to a tag directly, if
    there is only one tag match, otherwise present a list of tag
    matches.

    1. You can use the 'tjump' ex command. For example,

    :tjump func1

    will jump to the definition func1, if it is defined only
    once. If func1 is defined multiple times, a list of
    matching tags will be presented.
    2. You can position the cursor over the tag and press g
    Ctrl-].
    3. You can visually select a text and press g Ctrl-] to jump
    or list the matching tags.
    4. You can use the 'stjump' ex command. This will open the
    matching or selected tag from the tag list in a new window.
    5. You can press Ctrl-W g Ctrl-] to do a :stjump.

    Help keyword(s): :tjump, g_Ctrl-], v_g_CTRL-], :stjump,
    Ctrl-W_g_Ctrl-]

    13. How do browse through a list of multiple tag matches?

    If there are multiple tag matches, you can browse through all of
    them using several of the Vim ex commands.

    1. To go to the first tag in the list, use the 'tfirst' or
    'trewind' ex command.
    2. To go to the last tag in the list, use the 'tlast' ex command.
    3. To go to the next matching tag in the list, use the 'tnext' ex
    command.
    4. To go to the previous matching tag in the list, use the
    'tprevious' or 'tNext' ex command.

    Help keyword(s): :tfirst, :trewind, :tlast, :tnext, :tprevious,
    :tNext

    14. How do I preview a tag?

    You can use the preview window to preview a tag, without leaving
    the original window. There are several ways to preview a tag:

    1. You can use the 'ptag' ex command to open a tag in the
    preview window.
    2. You can position the cursor on a tag name and press Ctrl-W
    } to open the tag in the preview window.
    3. You can use the 'ptselect' ex command to do the equivalent
    of the 'tselect' ex command in the preview window.
    4. You can use the 'ptjump' ex command to do the equivalent of
    the 'tjump' ex command in the preview window.
    5. You can position the cursor on the tag and press Ctrl-W g}
    to do a :ptjump on the tag.

    Help keyword(s): :preview-window, :ptag, Ctrl-W_}, :ptselect,
    :ptjump, Ctrl-W_g}

    15. How do I browse through the tag list in a preview window?

    If there are multiple tag matches, you can browse through all of
    them in the preview window using several of the Vim ex commands.

    1. To go to the first tag in the list, use the 'ptfirst' or
    'ptrewind' ex command.
    2. To go to the last tag in the list, use the 'ptlast' ex command.
    3. To go to the next matching tag in the list, use the 'ptnext' ex
    command.
    4. To go to the previous matching tag in the list, use the
    'ptprevious' or 'ptNext' ex command.

    Help keyword(s): :ptfirst, :ptrewind, :ptlast, :ptnext,
    :ptprevious, :ptNext

    16. How do I start Vim to start editing a file at a given tag match?

    While starting Vim, you can use the command line option '-t' to
    supply a tag name. Vim will directly jump to the supplied tag
    location.

    Help keyword(s): -t

    17. How do I list all the tags matching a search pattern?

    There are several ways to go through a list of all tags matching a
    pattern.

    1. You can list all the tags matching a particular regular
    expression pattern by prepending the tag name with the '/'
    search character. For example,

    :tag /<pattern>
    :stag /<pattern>
    :ptag /<pattern>
    :tselect /<pattern>
    :tjump /<pattern>
    :ptselect /<pattern>
    :ptjump /<pattern>

    2. If you have the 'wildmenu' option set, then you can press
    the <Tab> key to display a list of all the matching tags
    in the status bar. You can use the arrow keys to move
    between the tags and then use the <Enter> key to select a
    tag.

    3. If you don't have the 'wildmenu' option set, you can still
    use the <Tab> key to browse through the list of matching
    tags.

    Help keyword(s): tag-regexp, wildmenu

    18. What options are available to control how Vim handles the tags
    file?

    You can use the following options to control the handling of tags
    file by Vim:

    1. 'tagrelative' - Controls how the file names in the tags file
    are treated. When on, the filenames are
    relative to the directory where the tags file
    is present.

    2. 'taglength' - Controls the number of significant characters
    used for recognizing a tag.

    3. 'tagbsearch' - Controls the method used to search the tags file
    for a tag. If this option is on, binary search
    is used to search the tags file. Otherwise,
    linear search is used.

    4. 'tagstack' - Controls how the tag stack is used.

    Help keyword(s): 'tagrelative', 'taglength', 'tagbsearch',
    'tagstack'

    19. Is it possible to highlight all the tags in the current file?

    Yes. Read the Vim online help on "tag-highlight".

    20. Is it possible to create a menu with all the tags in the current
    file?

    Yes. It is possible to create a menu with all the tags in the
    current file using a Vim script. Download the TagsMenu.vim script
    from the following link:

    http://members.home.net/jayglanville/tagsmenu/TagsMenu.html

    21. Is there a workaround to make the Ctrl-] key not to be treated as
    the telnet escape character?

    The default escape characters for telnet in Unix systems is
    Ctrl-]. While using Vim in a telnet session, if you use Ctrl-] to
    jump to a tag, you will get the telnet prompt. There are two ways
    to avoid this problem:

    1. Map the telnet escape character to some other character using
    the "-e <escape character>" telnet command line option

    2. Disable the telnet escape character using the "-E" telnet
    command line option.

    Help keyword(s): telnet-CTRL-]

    Pltag.pl

    pltag.pl is a very simple tagger for Perl. Generally it should be adapted to your own needs. It produces tag file example of which is reproduced below. It is distributed with Vim <http://www.vim.org/>, latest version always available at http://www.mscha.com/mscha.html?pltags#tools

    Written by Michael Schaap

    Here is an example of its output

    !_TAG_FILE_FORMAT 2 /extended format/
    !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted/
    !_TAG_PROGRAM_AUTHOR Michael Schaap /[email protected]/
    !_TAG_PROGRAM_NAME pltags //
    !_TAG_PROGRAM_VERSION 2.21 /supports multiple tags and extended format/
    addexempt antispam200.pl /^sub addexempt$/;" s file:
    delexempt antispam200.pl /^sub delexempt$/;" s file:
    er_severity antispam200.pl /^ my $er_severity=index("ATSEWID",$ercode);$/;" v file:
    ercode antispam200.pl /^ my $ercode=substr($_[0],0,1);$/;" v file:
    extract_dns antispam200.pl /^sub extract_dns {$/;" s file:
    fname antispam200.pl /^ my $fname="specialmes_$year$mday\\_$hour$min$sec";$/;" v file:
    get_addr antispam200.pl /^sub get_addr$/;" s file:
    i antispam200.pl /^ my $i;$/;" v file:
    i antispam200.pl /^ my $i;$/;" v file:
    left_dot antispam200.pl /^ my $left_dot=rindex($_[0],'.');$/;" v file:
    line antispam200.pl /^ my $line=$_[0];$/;" v file:
    list_reader antispam200.pl /^sub list_reader$/;" s file:
    logger antispam200.pl /^sub logger $/;" s file:
    lreader antispam200.pl /^sub lreader$/;" s file:
    malformed_addr antispam200.pl /^sub malformed_addr$/;" s file:
    message antispam200.pl /^ my $message=$erprefix.substr($_[0],1,255); $/;" v file:
    move antispam200.pl /^sub move # Move a file to directory based on $home$/;" s file:
    move_and_send antispam200.pl /^sub move_and_send$/;" s file:
    move_spam antispam200.pl /^sub move_spam # -- Move spam to archive$/;" s file:
    newdir antispam200.pl /^sub newdir {$/;" s file:
    normalize antispam200.pl /^sub normalize $/;" s file:
    parse_dns antispam200.pl /^sub parse_dns$/;" s file:
    populate antispam200.pl /^sub populate {$/;" s file:
    read_header antispam200.pl /^sub read_header$/;" s file:
    recover antispam200.pl /^sub recover $/;" s file:
    remail antispam200.pl /^sub remail $/;" s file:
    send_notice antispam200.pl /^sub send_notice $/;" s file:
    sendall antispam200.pl /^sub sendall $/;" s file:
    spamctrl antispam200.pl /^sub spamctrl$/;" s file:
    special_mes antispam200.pl /^sub special_mes $/;" s file:
    store antispam200.pl /^sub store$/;" s file:
    swords antispam200.pl /^ my @swords=split(\/\\s+\/,$subject);$/;" v file:

    sqltag.sh

    Since ctags does not directly support the Embedded SQL/C (ESQL) language, a simple shell script (sqltag.sh) can be used to create tags for sql.

    #!/bin/sh
    # Program to create ctags for ESQL, C++ and C files
    ESQL_EXTN=pc
    tag_file1=tags_file.1
    tag_file2=tags_file.2
    which_tag=ctags
    rm -f $tag_file1 $tag_file2 tags
    aa=`ls *.$ESQL_EXTN`
    #echo $aa
    for ii in $aa 
    do
    	#echo $ii
    	jj=`echo $ii | cut -d'.' -f1`
    	#echo $jj
    	if [ ! -f $jj.cpp ]; then
    		echo " "
    		echo " "
    		echo "***********************************************"
    		echo "ESQL *.cpp files does not exist.. "
    		echo "You must generate the *.cpp from *.pc file"
    		echo "using the Oracle Pro*C pre-compiler or Sybase"
    		echo "or Informix esql/c pre-compiler."
    		echo "And then re-run this command"
    		echo "***********************************************"
    		echo " "
    		exit
    	fi
    	rm -f tags
    	$which_tag $jj.cpp
    	kk=s/$jj\.cpp/$jj\.pc/g
    	#echo $kk > sed.tmp
    	#sed -f sed.tmp tags >> $tag_file1
    	#sed -e's/sample\.cpp/sample\.pc/g' tags >> $tag_file1
    	sed -e $kk tags >> $tag_file1
    done
    # Now handle all the C++/C files - exclude the ESQL *.cpp files
    rm -f tags $tag_file2
    bb=`ls *.cpp *.c`
    aa=`ls *.$ESQL_EXTN`
    for mm in $bb 
    do
    	ee=`echo $mm | cut -d'.' -f1`
    	file_type="NOT_ESQL"
    	# Exclude the ESQL *.cpp and *.c files
    	for nn in $aa 
    	do
    		dd=`echo $nn | cut -d'.' -f1`
    		if [ "$dd" = "$ee" ]; then
    			file_type="ESQL"
    			break
    		fi
    	done
    	if [ "$file_type" = "ESQL" ]; then
    		continue
    	fi
    	rm -f tags
    	$which_tag $mm
    	cat tags >> $tag_file2
    done
    mv -f $tag_file2 tags
    cat  $tag_file1 >> tags
    rm -f $tag_file1
    # Must sort tags file for it work properly ....
    sort tags > $tag_file1
    mv $tag_file1 tags
    The shell script given below can be used to generate tags for a very large variety of programs written in JavaScript, PHP/FI scripts, Korn shell, C shell, Bourne shell and many others. This is a very generic module.

    Save this file as tags_gen.sh and do chmod a+rx tags_gen.sh.

    #!/bin/sh
    tmp_tag=tags_file
    tmp_tag2=tags_file2
    echo " "
    echo " "
    echo " "
    echo " "
    echo " "
    echo "Generate tags for ...."
    while :
    do
    	echo "    Enter file extension for which you want to generate tags."
    	echo -n "    File-extension should be like sh, js, ksh, etc... : "
    	read ans
    	if [ "$ans" == "" ]; then
    		echo " "
    		echo "Wrong entry. Try again!"
    	else
    		break
    	fi
    done
    \rm -f $tmp_tag
    aa=`ls *.$ans`
    for ii in $aa
    do
    	jj=`echo $ii | cut -d'.' -f1`
    	#echo $jj
    	cp $ii $jj.c
    	ctags $jj.c
    	echo "s/$jj.c/$ii/g" > $tmp_tag2
    	sed -f $tmp_tag2 tags >> $tmp_tag
    	\rm -f tags $jj.c
    done
    sort $tmp_tag > tags
    \rm -f $tmp_tag $tmp_tag2



    Etc

    Society

    Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy

    Quotes

    War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes

    Bulletin:

    Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law

    History:

    Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

    Classic books:

    The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Hater’s Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

    Most popular humor pages:

    Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

    The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D


    Copyright © 1996-2021 by Softpanorama Society. www.softpanorama.org was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

    FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

    This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

    You can use PayPal to to buy a cup of coffee for authors of this site

    Disclaimer:

    The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the Softpanorama society. We do not warrant the correctness of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

    Last modified: March 12, 2019