Reputation: 1033
In Vim editor I opted ]I
on a function (in C++ code).
This presented a list, which says 'Press ENTER or type command to continue'.
Now to jump to an occurrence say 6, I type 6
- but this is not working.
What commands can I type in such a case, and how do I jump to Nth occurrence from this list?
Update:
Actually I tried :N (eg :6) - but the moment I type :
Vim enters Insert mode, and the colon gets inserted in the code instead.
Update
Assuming :N approach is correct, still complete uninstall and install of Vim, without any configuration, too did not help - though now typing :
does not switch Vim to insert mode.
Upvotes: 6
Views: 2533
Reputation: 531
I had the same problem, and cobbling together the previous answers and experimenting I came up with this solution:
[I // gives list of matches for word under cursor, potentially some matches are in headers. remember the number of the match you're interested in, eg. the 3rd
q // quits the list of matches
3[Ctrl-i // (with cursor in same position) jumps to third match
Upvotes: 1
Reputation: 127588
[I
only lists the search results. To jump to the results use the sequence [ CTRL+I
.
You can see the full list of relevant jumps at:
http://www.vim.org/htmldoc/tagsrch.html#include-search
Upvotes: 0
Reputation: 15073
If you hit a jump button, and get a list of possible targets, select the number, and hit the jump again.
So given
1: 345 my_func (int var)
2: 4523 my_func (int var)
3: 10032 my_func (3);
If you hit '2]|', it should jump directly to that line.
Upvotes: 1
Reputation: 83990
Do :h tselect on vim to see the complete definition
If you already see the tag you want to use, you can type 'q' and enter the number.
Upvotes: 1
Reputation: 42638
When I use vim, and I jump to a tag, by doing for instance:
:tag getfirst
I get presented with something that looks like:
# pri kind tag file
1 F m getfirst /home/sthorne/work/.../FormData.py
class:FakeFieldStorage
def getfirst(self, k, default):
....
8 F m getfirst /home/sthorne/work/.../CGIForm.py
class:CGIForm
def getfirst(self, name):
Choice number (<Enter> cancels):
I type '5' to go to the 5th occurrence.
If you can't get your vim to have that behaviour (it seems to be on by default for my vim), you can use g] instead of ctrl-], which is analagous to :tselect instead of :tag
Upvotes: 0
Reputation: 200946
It should present you a list like:
1: 345 my_func (int var)
2: 4523 my_func (int var)
3: 10032 my_func (3);
The second column is line numbers. Type :345 to jump to line 345.
Upvotes: 2