tags:

views:

672

answers:

8

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 case, and how do I jump to N 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.

+1  A: 

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.

John Millikin
A: 

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

Jerub
A: 

John Actually I tried :N (eg :6) - but the moment I type : Vim enters Insert mode, and the colon gets inserted in the code instead.

vikramsjn
Sounds like you have a very unusual configuration. How do you enter commands like :w if colon enters insert mode?
John Millikin
:w is not entering insert mode. And everything else seems to work fine. Actually I remember using :N some time ago, but today suddenly its seems to have stopped working. Though I don't think I have changed my Vim cfg file for an year now.
vikramsjn
So, when you type :w it works perfectly, but when you type :6 as soon as you type the colon it's inserted into the code? You don't need StackOverflow, you need a young priest and an old priest.
John Millikin
Thanks. I get your point.
vikramsjn
+1  A: 

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.

jop
A: 

Try using 123G to go to line 123 (see :h G).

Roman Odaisky
A: 

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.

zigdon
A: 

[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

Nathan Fellman
A: 

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
thoughton