I found a useful map at the include-search ([I) help.

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

This opens the file found on the line I type (after [I displaying all assurances of current line). I don't understand the syntax, I want to modify- opening the file in new tab.

  • Welcome to Vi and Vim! Which parts of the syntax are confusing? It would be helpful to see your understanding so we can focus on the relevant parts.
    – D. Ben Knoble
    Nov 28, 2022 at 15:39
  • 1
    Note, though, that the mapping is effectively [I followed by <nr>[<Tab> which is the same as <nr>[<C-i>. Near that help page, we can find <C-w>i for splitting and :ijump which allows more control. If you really want a new tab, try :execute 'tab isplit' nr expand('<cword>') or execute 'normal!' nr."\<C-w>i\<C-w>T"
    – D. Ben Knoble
    Nov 28, 2022 at 15:42
  • Thanks , what is the expand(<cword>) and what is the ! after normal?
    – barak.o
    Nov 30, 2022 at 18:17
  • Pro-tip: learn to use :help :) for example, :help expand() and :help :normal have the answers you are looking for.
    – D. Ben Knoble
    Nov 30, 2022 at 21:04


Your Answer

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

Browse other questions tagged or ask your own question.