1

[I

Display[s] all lines that contain the keyword under the cursor.

When I do so, it shows the matching files and lines and says

Press ENTER or type command to continue.

What command(s) can I type here, if any? Can I quickly jump to the file and line [I outputs (without doing :e filename etc.)?

1 Answer 1

4

Looks like :<line number> or :e filename is the best you can do. (Well, except for the convenience mapping that I found in Vim help. Jump to the "update" at the end of this post if you're not interested in the context.)

I don't believe there are any commands specific to [I. That's the standard message for paged results so the available commands are mostly related to moving up and down in case the results take up more than the window can contain at once.

When you have more than a page worth of results you'll see

-- More --

If you then type ? (or any unrecognized command, I think) you'll see

SPACE/d/j: screen/page/line down, b/u/k: up, q: quit

(The 'more' option must be enabled to see this.)

There are a few more such as : which will take you to command line while the page of results is still displayed. And therein lies the best answer I have for your specific question. Hit : and enter in the command with the line number or filename or whatever which is displayed next to the line of interest. Hey at least you won't forget it and have to bring the results back up. (Though if you did, note g< described next.)


See :h pager for a complete list of available commands. It's worth a read and includes explanation of the somewhat obscure g< command...

...used to see the last page of previous command output. This is especially useful if you accidentally typed <Space> at the hit-enter prompt.

I know I often accidentally exit out of the last page of output so g< is a nice little command to get back there without having to think much about it.


Update: :h include-search (scroll down a bit) has the following mapping using [I that could make jumping to lines a little easier...

:map <F4> [I:let nr = input("Which one: ")<Bar>exe "normal " . nr ."[\t"<CR>

Use F4 instead of [I and on the last screen a prompt will say "Which one:". Select the result number (not the line number) and hit Enter and you will be taken to that line. Not earth shattering stuff but nominally more convenient.

3
  • Perhaps the map should be at the top of the answer so it isn’t drowned out?
    – D. Ben Knoble
    Dec 5, 2018 at 18:30
  • 1
    @D.BenKnoble That would require some rewriting/reorganizing that I'd rather avoid for a relatively tame mapping. I see your point, though, so I at least added a blurb at the start noting its presence. Cheers.
    – B Layer
    Dec 6, 2018 at 6:27
  • As a side node: \t in exe "normal " . nr ."[\t" is equivalent to CTRL-I and then it's actually executing [ CTRL-I. I found this tidbit under section JUMPING TO A MATCH in :help usr_29.txt Jun 12, 2019 at 22:02

Your Answer

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

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