7

How can I open the result of ctrl+] in a new split?

similar: How do I open a tag with ctrl+] but open it in an existing split?

2
  • 1
    I can’t find any reference to it, but does <C-w><C-]> work?
    – D. Ben Knoble
    Dec 7, 2018 at 2:17
  • @D.BenKnoble Yes, it does! (albeit a horizontal split)
    – Geremia
    Dec 7, 2018 at 3:49

1 Answer 1

7

This will do it:

CTRL-W ]                    *CTRL-W_]* *CTRL-W_CTRL-]*
CTRL-W CTRL-]   Split current window in two.  Use identifier under cursor as a
        tag and jump to it in the new upper window.
        In Visual mode uses the Visually selected text as a tag.
        Make new window N high.

courtesy: D. Ben Knoble

4
  • 1
    One could even remap the commands to use a vertical split
    – D. Ben Knoble
    Dec 7, 2018 at 4:06
  • how? @D.BenKnoble Jul 13, 2021 at 11:14
  • 1
    @AyushMandowara e.g., nnoremap <C-w>] :vertical stag <cword><CR>. <C-w>] and variants are just aliases for :stag <cword><CR> if you read the description.
    – D. Ben Knoble
    Jul 13, 2021 at 17:56
  • It's not strictly true that they're aliases. If you use these Ex-command formulation, a different "flags" argument gets passed to :help tag-function. With regular <C-w>] the flag 'c' is passed, while your formulation passes an empty flag.
    – Aktau
    Dec 1, 2021 at 23:15

Your Answer

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.