I use the vertical split command a lot :vsplit, and I also have click on ctrl] to look at the definition of a variable (after generating the Ctags).

I would like to do a keyboard shortcut that does both like so: I see a variable I would like to see the definition of, so I put the cursor ontop of that variable, perform the keyboard shortcut, and then a vertical split on the right side should show with the definition of that variable (even if it's defined in the same file).. then I perform another keyboard shortcut to dismiss that new window and return to exactly where I was

How do I do that?

  • There is CTRL-W CTRL-] already to open the definition in a split. However, this opens a horizontal split, so it is not exactly what you want. Jan 16, 2018 at 7:34
  • what does CTRL-W really mean? where can i find a documentation for it? I see it used everywhere
    – abbood
    Jan 16, 2018 at 8:12
  • 2
    @abbood To know what CTRL-W means, you can try :h CTRL-W ;) It is the first part of the Window commands which allow to split, move, change the size (etc) of the windows.
    – statox
    Jan 16, 2018 at 9:12

1 Answer 1


From the command line this will open a new vertical split with the tag target:

:vert winc ]

:winc ] is the command line equivalent of the CTRL-W CTRL-] key combo mentioned in a comment above...except neither the Normal mode version nor the command line version require the second Ctrl. CTRL-W ] is sufficient.

(In fact, many of the CTRL-W commands have variations where the second Ctrl is optional. The idea is to be forgiving if the user is rapidly pressing the keys and doesn't release Ctrl quickly enough after Ctrl+W.)

Then we have the modifier :vert that for certain commands that open a horizontal split opens a vertical split instead. That's why we're using the command line for this rather than the Normal mode keys.

Anyways, sounds like you want a Normal mode mapping for it so

:nnoremap XX :vert winc ]<CR>

Change XX to whatever unused key combo you prefer.

To close the window and return to where you were press Ctrl+W followed by C.

  • @abbood Did this work for you?
    – B Layer
    Jan 22, 2018 at 21:48
  • worked perfect @B Layer.. how can i have two different shortcuts one for vertical split on jump to definiton and another horizontal one?
    – abbood
    Apr 25, 2018 at 6:15
  • You mean the same mapping as above except with a horizontal split? Just leave off vert. As it says, vert is a modifier that alters a command that normally opens a horizontal split.
    – B Layer
    Apr 25, 2018 at 11:12

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.