Vim and ctags: tag filenames
Asked Answered
H

4

17

Is it possible to have ctags generate tags for filenames as well? I would like to be able to jump to a file given a filename. :find seems to be awfully slow compare to tags...

Halland answered 14/6, 2011 at 18:6 Comment(0)
C
15

Try running ctags -R --extra=f .

The --extra=f option tells ctags to:

"Include an entry for the base file name of every source file (e.g. "example.c"), which addresses the first line of the file."

When you open vim, you can the use :tag <filename> to jump to the first line of the file.

Czarina answered 14/6, 2011 at 19:53 Comment(1)
using extra=+f AND --langmap=FILE:.html.twig.xml.yml you can have easilly access to any type of file: github.com/docteurklein/dot-files/blob/master/ctags#L23 `Dichromaticism
G
6

You can open the filename under the cursor with gf

http://vim.wikia.com/wiki/Open_file_under_cursor

Genisia answered 14/6, 2011 at 18:9 Comment(2)
I tried to set path to <mycode>** then use gf... it is almost as slow as find.Halland
It's worth noting that gf only works for files in the current path. If your tag file contains information about shared libraries (i.e. stdio.h), you will want to use Tim Henigan's answer.Chammy
C
3

You can also use cscope:

:cs find f <filename>

or, if you've setup cscope in vim as recommended in :help cscope, put the cursor on top of a filename, and press <C-_>f.

Commeasure answered 14/6, 2011 at 18:48 Comment(0)
L
1

Have you tried setting your path and then using vim's 'gf' command?

Lynnettelynnworth answered 14/6, 2011 at 18:8 Comment(1)
I tried to set path to <mycode>** then use gf... it is almost as slow as find.Halland

© 2022 - 2024 — McMap. All rights reserved.