Vim: Possible to make default split vertical when opening help or file instead of horizontal?

7

1

When using :help, it splits the window horizontally and opens the help in the top window. I then need to use ^w L to move the help window to the right. Same thing if use ^w f to open a file under the cursor, the window is split horizontally and the file is opened in the top window.

Is there a way to have these commands split the window vertically instead?

Matthew

Posted 2013-04-14T17:48:22.060

Reputation: 966

Answers

4

Vim provides these commands:

:vert[ical] {cmd}
    Execute {cmd}.  If it contains a command that splits a window,
    it will be split vertically.

:[count]winc[md] {arg}
    Like executing CTRL-W [count] {arg}.

Therefore:

  • To open a vertical help window type :vert help
  • To edit the file name under cursor in a new vertical split type :vert winc f

Marco Baldelli

Posted 2013-04-14T17:48:22.060

Reputation: 286

1

This moves the help window once. So you can freely move it around after the window is created.

if has('autocmd')
  function! ILikeHelpToTheRight()
    if !exists('w:help_is_moved') || w:help_is_moved != "right"
      wincmd L
      let w:help_is_moved = "right"
    endif
  endfunction

  augroup HelpPages
    autocmd FileType help nested call ILikeHelpToTheRight()
  augroup END
endif

The function, ILikeHelpToTheRight() will only run wincmd L once per window (it's what the w: prefix is for).

docwhat

Posted 2013-04-14T17:48:22.060

Reputation: 276