Skip navigation.
Home

Reply to comment

Using Ctags in Vim

Generate a tags file using ctags

$ ctags *.c
$ ctags -R .
$ ctags -L flist

For Linux kernel and some other packages which have built-in tags target in Makefile:

$ make tags

Configure Vim to locate a tags file

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

My ctags settings in ~/.vimrc:

"ctags settings
set tags=tags,../tags,../../tags,../../../tags,../../../../tags,../../../../../tags,../../../../../../tags

Jump to a tag

  • :tag <tagname>
  • position the cursor over a tag name and then press:
    Ctrl-]
  • $ vim -t <tagname>

Come back from a tag jump

  • :pop
  • Ctrl-t

Reference

  1. Tip #94: Questions & Answers about using tags with Vim.
  2. Ctags Home Page.

    Reply

    The content of this field is kept private and will not be shown publicly.
    • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <h1>
    • Lines and paragraphs break automatically.
    • Web page addresses and e-mail addresses turn into links automatically.

    More information about formatting options

    CAPTCHA
    This question is for testing whether you are a human visitor and to prevent automated spam submissions.
    7 + 12 =
    Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.