Vim can be used for Perl editing. Vim is not as great as specialized IDS but
still you can achieve quite a lot by careful customarization. VIM provides
syntax highlighting coding for Perl. The most important thing to learn are
first additional ctags.
When using tags it is nice to have two windows split horisontally. Vim supports
both vertical and horizontal window splitting. To split current window horizontally
execute :split while in the normal mode. To split current window
vertically, use :vsplit instead. If you dont provide any filename
as argument to split/vsplit then current filename is used. You further split resulting
windows as much as you like. Use Ctrl-w w to cycle through the windows.
:close will close the current windows. :only will
close all windows except the current one.
Vim provides facilities for reconsiling differences between two Vim will show both
files in vertical split window mode. When you will scroll in one window, Vim will
automatically scroll another window for you. You can patch the individual differences
using do and dp commands. do will get the
patch from the neighbor window and apply it to the current buffer, while dp
will apply the difference from the current buffer to the neighbor window. If you
need more information on this topic, read file /usr/share/doc/vim-common-6.1/docs/diff.txt.
Text wrapping
As you code, sometimes text flows further than the width of the
editor window. Some people like long lines to be wrapped (in other
words, continued on the other line), while others prefer them
unwrapped. You can configure Vim to behave according to your liking
by adding set wrap or set nowrap to
your .vimrc configuration file.
Flexible tabs
Tabulation is one of the hottest topics in programmers
discussions when it comes to style. A very nice explanation of what
is the problem with tabulations and spaces can be read at
http://www.jwz.org/doc/tabs-vs-spaces.html. I must say though,
that I dont agree with authors position on the subject. The article does provide you with several options for vi/Vim
configuration to control the behavior of the tabs. I will just
add/repeat the ones I consider important.
- Add
set tabstop=4 to your .vimrc to
display all occurrences of Tab character (ASCII #9) as 4 spaces.
This option will not change the text, it will only change the
displaying of the text.
- Add
set autoindent to your .vimrc for
Vim to automatically position the cursor with appropriate
indentation level when you press Enter and want to write the next
line of code. This is very useful when you are indenting your code
in structures like loops and procedures.
- Vim allows you to select a block of code and change its
indentation level (either increase or decrease the level). Control
the width of the indentation level with
set shiftwidth=4
in your .vimrc configuration file.
If you need more information on this topic, read file
/usr/share/doc/vim-common-6.1/docs/indent.txt.
Line numbering
While Vim always displays your current position in the status
line, you might also want to see all lines numbered. To do that, you
will need to add set number to your .vimrc.
If you need more information on this topic, read file
/usr/share/doc/vim-common-6.1/docs/usr_03.txt.
Syntax highlighting
The first thing any developer will notice in Vim is excellent
syntax highlighting. All popular languages are supported. Syntax
files for less popular are available from Vim web site. Perl is
supported out of the box.
Vim identifies keywords, comments, variables, strings, in-line
POD and other standard parts of the program and highlights them. Vim
supports two color modes: one for terminals with dark background
color and another one for terminals with light background color. You
can control these modes by specifying command set bg=dark
and set bg=light in your .vimrc.
If you still dont like the appearance of the code, stay tuned
until Color schemes discussion.
If you need more information on this topic, read file
/usr/share/doc/vim-common-6.1/docs/syntax.txt.
Text completion
One of Vims features I cannot live without is text completion.
When editing, press Ctrl-n / Ctrl-p to
cycle through the current word completion suggestions. Vim generates
suggest list based on the words in the current file. If you need key
completion to make suggestions from other files, then Vim by default
understand the ctags file. Simply run ctags *.p?
to generate ctags for all Perl files and modules in the current
directory (assuming you are using .pl extension for
Perl scripts and .pm extension for Perl modules).
This Vims feature not only saves a tonne of time on typing, but
greatly decreases the error rate, especially with long variable and
procedure names in the code.
If you need more information on this topic, read file
/usr/share/doc/vim-common-6.1/docs/usr_24.txt.
File Completion
While you are in the command mode, Vim can complete the names of
files and directories in case you want to open or save a file. In
order to complete a file or a directory name you should start typing
its name on the command prompt and then press the completion key.
You can change the completion key to be almost anything you want
with set wildchar= line in your .vimrc
file.
Window splitting
Sometimes
I need to see two or more files simultaneously. While I can always
start another Vim session in a separate terminal, it is not as
comfortable at times as Vims window splitting feature.
Vim supports both vertical and horizontal window splitting. To
split current window horizontally execute :split
while in the normal mode. To split current window vertically, use :vsplit
instead. If you dont provide any filename as argument to split/vsplit
then current filename is used. You further split resulting windows
as much as you like. Use Ctrl-w w to cycle through the
windows. :close will close the current windows. :only
will close all windows except the current one.
If you need more information on this topic, read file
/usr/share/doc/vim-common-6.1/docs/usr_08.txt.
Diff mode
Vim
provides excellent facilities for checking and editing differences
between two or more files. Execute vimdiff main.pl main2.pl
(or vim -d main.pl main2.pl) from the command line to
see difference made to file main.pl in file main2.pl.
Vim will show both files in vertical split window mode. When you
will scroll in one window, Vim will automatically scroll another
window for you. You can patch the individual differences using
do and dp commands. do will get the
patch from the neighbor window and apply it to the current buffer,
while dp will apply the difference from the current
buffer to the neighbor window.
If you need more information on this topic, read file
/usr/share/doc/vim-common-6.1/docs/diff.txt.
Text folding
Yet
another popular feature found in popular editors and IDEs is text
folding. I think that folding is easier shown then explained. Vim supports six folding methods: by indent, by expression, by
syntax, by changes in the text, by marker, and manual folding. For the sake of the example, I will
show how to configure folding by marker.
In order to tell Vim to use folding by marker add the following
lines to your .vimrc:
" Folding configuration
set foldmethod=marker
" Edit and uncomment next line if you want non-default marker
"set foldmarker="{{{,}}}"
If you need more information on this topic, read files
/usr/share/doc/vim-common-6.1/docs/usr_28.txt and
/usr/share/doc/vim-common-6.1/docs/fold.txt.
Marks
One of Vims features that speeds up navigation is marks. You
can set a mark anywhere in the text and then quickly jump back to
it. You can set several marks. You can set marks in several files
and then quickly switch between them. I find myself set mark on the
place I am currently working at with mc (m
is for mark, c I use for current) and then quickly
returning to the same place with 'c.
If you need more information on this topic, read file
/usr/share/doc/vim-common-6.1/docs/motion.txt.
Vertical Indent Display
For
some people indenting text horizontally is not enough. They need
some kind of vertical indentation to help them see corresponding
parts of the code. While I am not one of those people, Ive seen
this feature around so often that I decided to add it codemonkeys
.vimrc.
All you need to do to have vertical indent display with pipe
(|) character is to add the following two lines to your .vimrc.
" This is for vertical indenting
set list
set listchars=tab:|
" NOTE the space char after last backslash.
:set list forces Vim to show hidden characters
like tabulations, ends of lines, and ends of files. :set
listchars=tab:| asks Vim to show only tab characters and
use a pipe (|) with a space ( ) to do so, instead of usual ^I
thing that Vim likes to show.
Color schemes
Robert (MetaCosm) downloaded all color schemes and put them into a
single archive file which he uploaded back to Vims web site (http://www.vim.org/scripts/script.php?script_id=625.).
You will most likely notice that some color schemes do not
change much colors in your console vim. That is
because they are most probably designed for GUI version of Vim,
called gvim.
Try executing gvim +'colorscheme peachpuff' main.pl
to see how gvim looks with selected color scheme.
Now
you can try all those color schemes one by one with :colorscheme
something and choose the one you like best. When you are
done choosing, add line colorscheme something to your
.vimrc.
If you need more information on this topic, read file
/usr/share/doc/vim-common-6.1/docs/usr_06.txt.
Block commenting
It
is an often need to comment or uncomment blocks of code during the
development cycle. While there is a way to do it in Vim without any
additional configuration, I try to make life as easy as possible and
install the BlockComment plug-in by Chris Russell.
Lets download BlockComment.vim from
http://www.vim.org/scripts/script.php?script_id=473 and copy it
into .vim/plugin/ directory. This plug-in automatically
provides us with two mappings: .c for commenting code
and .C for uncommenting code back.
File and buffer browser
Vim
supports editing of several files simultaneously. One can start Vim
as vim main.pl main2.pl and then use :next
and :previous to navigate through open files (called
buffers). It is also possible to open files for editing without
quiting Vim every time. For that, one should use simple :e
main2.pl command, where main2.pl is the name of needed file.
There are, as usual, better (more convenient) ways to work with
files and buffers. Vim website lists few plug-ins which can handle
only files, or only buffers, or both at the same time. One of those
plug-ins is winmanager by Srinath Avadhanula. Lets grab winmanager
from
http://www.vim.org/scripts/script.php?script_id=95.
Vims winmanager plug-in can make use of bufexplorer plug-in by
jeff lanzarotta availalbe from
http://www.vim.org/scripts/script.php?script_id=42.
Installation is as usual saving, unziping, and dos2unixing.
Since we dont want to always have file/directory browser turned on,
lets add a mapping line to our .vimrc to :WMToggle
by F2.
" This is for winmanager
map <F2> :WMToggle<CR>
If you need more information on this topic, read file
/usr/share/doc/vim-common-6.1/docs/usr_23.txt.
Tag explorer
If
you ask me, I am almost happy. The last thing that I am missing is
something that will ease up my code browsing. I need a fast way of
switching between different parts of my code and hierarchical view
of it. Once again I go fishing to Vim web site and get myself a nice
looking taglist plug-in by Yegappan Lakshmanan from
http://www.vim.org/scripts/script.php?script_id=273. This one is
not even an archive! You just need to copy it into your
.vim/plug-in directory. Lets map :Tlist
command to F3 key.
" This is for taglist
map <F3> :Tlist<CR>
One annoying thing that I find about taglist is that it resizes
the terminal window when possible. I prefer to switch this feature
off by add modifying my .vimrc in the following way.
" This is for taglist
let Tlist_Inc_Winwidth = 0
map <F3> :Tlist<CR>
If you need more information on this topic, read file
/usr/share/doc/vim-common-6.1/docs/tagsrch.txt.
Perl syntax checking
..copy perl.vim (developed
by Lukas Zapletal) into your .vim/compiler/ directory.
Now we need to specify for which files we want Vim to use our new
perl compiler scripts. This is easily done by adding the following
lines to .vimrc.
" Use perl compiler for all *.pl and *.pm files.
autocmd BufNewFile,BufRead *.p? compiler perl
Now you can use :make to check your code for
errors. If you do have problems in your code, then Vim will position
the cursor on the line with the first problem. You can use :cnext
and :cprevious to go through other error messages. :clist
will show a list of all errors.
If you need more information on this topic, read file
/usr/share/doc/vim-common-6.1/docs/usr_30.txt.
You can also check perl syntax in VIM on each save
au BufWritePost *.pl,*.pm !perl -c %
With this macro every time you save a .pl or .pm file, it executes perl -c and shows you
the output.
Perldoc integration
Yet
another feature provided in most IDEs is on-line documentation. Vim
helps developers even with that. By default, Vim comes with system
manual support on all UNIX boxes. This comes very handy when you use
system commands in your scripts and need to check command line
parameters. Just position the cursor on the word that you are
interested in and press K. Vim will execute man
word, where word is the word under the cursor. This is
helpful but not as much as we need it.
Lets visit Vim site again and download Perldoc plug-in
(developed by Colin Keith) from
http://www.vim.org/scripts/script.php?script_id=209. unzip
perldoc.zip and run all extracted files through
dos2unix. Its a good idea to add a F1 mapping
to :Perldoc in your .vimrc.
" This is for perldoc.vim
autocmd BufNewFile,BufRead *.p? map <F1> :Perldoc<cword><CR>
autocmd BufNewFile,BufRead *.p? setf perl
autocmd BufNewFile,BufRead *.p? let g:perldoc_program='/usr/bin/perldoc'
autocmd BufNewFile,BufRead *.p? source /home/codemonkey/.vim/ftplugin/perl_doc.vim
If you are using a newer version then I do, then you skip the
last line.
Now, whenever you hit F1 while in the perl file, :Perldoc
will get executed for the word that you have under the cursor, your
current window will split horizontally and youll see appropriate
perldoc page.
After installation of this plug-in I have noticed that syntax
highlighting in few of my programs broke. After a quick look, I
understood that that happened because of my extensive usage of
underscore (_) character in procedure names. I had to fix it by
simply adding underscore (_) character to the list of keyword
characters on line 14 in file .vim/ftplugin/perl_doc.vim.
" Adds / and . as used in requires.
" setlocal iskeyword=a-z,A-Z,48-57,:,/,.
" Adds / and . as used in requires. Also adds _ as used in procedure names.
setlocal iskeyword=a-z,A-Z,48-57,:,/,.,_
au BufWritePost *.pl,*.pm !perl -c %
Every time you save a .pl or .pm file, it executes perl -c and shows you
the output.
~~
naChoZ
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. |
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.
Update:
This post was translated into
Portuguese by Alceu Rodrigues de Freitas Junior.
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-]
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:
- Generate a perl "tags" file. Here's the
script (ptags.pl) referenced to in the VIM help files that generates
perl tags.
Here are the usage lines from the script:
USAGE: ptags.pl [-mvwV] [-t <file>] <files>
-m Merge with existing tags file.
-t <file> Name of tags file to create. (default is 'tags')
-v Include variable definitions. (variables mentioned at the start of a
line)
-V Print version information.
-w Suppress "duplicate tag" warnings.
<files> List of files to scan for tags
If you want the tags file to include libaries
just use the -m option to merge it in or create a new one with all the library
paths (lib_path/*). Something like:
find /usr/lib/perl5 -name *.pm -type f -exec
ptags.pl -m -t path_to_tags_file {} \;
- Set the tags variable if needed in your
.vimrc. (Do a :set tags to see what the tags search path currently looks
for).
- You're done! Edit any perl file and hover
your cursor over a function name. Try hitting CTRL-] (Control - Right Square
Bracket) in command mode, it should jump you to the function declaration.
Press CTRL-T to get back to your original location/file. You can jump "in"
to as many functions are you want, your return location is kept in a stack,
so continual tapping of CTRL-T should return you back to your original 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!