VIM41
To turn any of these indent modes on, with the application in Normal mode, type
:set
. To turn off an indent mode, simply preface the mode name with the word
no
”. For example, to turn on
cindent
, type:
:set cindent
To turn
cindent
back off, type:
:set nocindent
2.4.3Using Tags with VIM
The
ctags
program can be used to build a tags file that is readable by VIM and can be
used to quickly navigate among multiple source code files. Building the tags file is done in the
same way as described earlier in the chapter for Jed, but you must us the
ctags
program
instead of
etags
.
$ ctags *.[ch]
This builds the
tags
file in the current directory.
To build a tags file for an entire project that spans many subdirectories, from the main
project directory, issue the
ctags
command with the –R option to recurse the directories.
$ ctags -R
From within VIM, if you need to jump to a particular function that is in the current file,
place the cursor on the appropriate function and press
^]
. This command uses the tags file to
locate the function and reads that file into the buffer.
To open a file and locate a function that is not present in the current buffer, type:
:tag
where <
tagname
> is the name of the function that you are looking for. This will load the
file into the buffer and position the cursor at that appropriate tag.
To list the tags that you have jumped to in this editing session, type
:tags
. The output
from this command is shown below.
:tags
# TO tag FROM line in file/text
1 1 main 1 ./arch/alpha/boot/tools/mkbb.c
2 1 perror 116 ./arch/alpha/boot/tools/mkbb.c
>
By pressing the number listed in the left column, you can return to previously accessed tags.
In large projects, it would not be uncommon for one function to be referenced in several
places. In the event that multiple tags are created with the same name, you can select from the
list of similar tags by using the
:tselect
command. To select from a list functions, type
:tselect
>. When the
tselect
command completes, you will be presented
Next Page >>
<< Previous Page
Back to the Table of Contents