6

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.

0

7 Answers 7

2

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.

4
  • 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
    Sep 26, 2008 at 6:03
  • Sounds like you have a very unusual configuration. How do you enter commands like :w if colon enters insert mode? Sep 26, 2008 at 6:06
  • :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
    Sep 26, 2008 at 6:09
  • 1
    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. Sep 26, 2008 at 6:10
1

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.

1

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.

1

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
0

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

0

[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

-2

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

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.