14

I know gf opens the file under cursor, and CTRL-w f opens the file under cursor in a new split window.

I'm probably being greedy but, how do you open it in a new vertical window?

Bastian Venthur
  • 12,515
  • 5
  • 44
  • 78
Dunctem
  • 317
  • 2
  • 12

1 Answers1

16

From normal mode, you could type C-w f C-w L or C-w v gf, and from the command-line you could execute :wincmd f | wincmd L or :vert wincmd f.

They are not strictly equivalent, though.

With C-w f C-w L and :wincmd f | wincmd L, the height of your vertical viewport will be maximized no matter the current layout. So, for example, if you have a horizontal viewport below, its width should be decreased:

        +-----------------+     +--------+-------+
        |  path/to/fileC  |     |        |       |
        |                 |  →  |        |       |
        |      fileA      |     |  fileA | fileC |
        +-----------------+     +--------+       |
        |                 |     |        |       |
        |      fileB      |     |  fileB |       |
        +-----------------+     +--------+-------+

With C-w v gf and :vert wincmd f, the height of your vertical viewport should be the same as the current one, and thus it shouldn't affect the horizontal viewport below:

        +-----------------+     +--------+-------+
        |  path/to/fileC  |     |        |       |
        |                 |  →  |        |       |
        |      fileA      |     |  fileA | fileC |
        +-----------------+     +--------+-------+
        |                 |     |                |
        |      fileB      |     |      fileB     |
        +-----------------+     +----------------+
user852573
  • 1,700
  • 1
  • 9
  • 15