Go to the file specified in Vim

In Vim, you can use the [I command to display all places where the specified function, class, or structure is declared or used. Is there a simple shortcut to open one of the files in this resulting list in Vim? I would prefer not to enter the full file name and line number.

+8
vim
source share
3 answers

I remembered the old gF trick that works great.

Shameless break with vim tips:

The following commands open the file with the cursor on the specified line number:

 gF open in the same window <cw>F open in a new window (Ctrl-w F) <cw>gF open in a new tab (Ctrl-w gF) 

When such file name / line number pairs result from compiling code, the following commands are also useful:

 :help :cn :help :cl :help :cfile 

The file: line plugin allows you to use combinations of the file name and line number, for example global.h: 123, as an argument to Vim. When you open the file: line, the script checks if the file exists and the line is a number. If so, Vim opens the file with the correct line number.

+5
source share

I use ctags in vim, which allows me to use C-] to jump to the definition of a function / structure / any. You can use these simple steps to configure it, and as soon as you have this question contains a bunch of useful shortcuts.

Actually, this question I just mentioned contains a lot of tips that you may find useful (not just related ctags).

0
source share

This is not very ergonomic, but after closing the list <Cw>i a new window opens with the cursor located in the first copy of the word.

Adding a counter as 3<Cw>i opens a new window with the cursor located on the third copy of the word.

0
source share

All Articles