Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim: open 4 files split horizontally AND vertically

Tags:

vim

viewport

On the command line, vim can open 4 files split horizontally,

vim -o file1 file2 file3 file4

or 4 files split vertically,

vim -O file1 file2 file3 file4

How do I open 4 files such that they are split both horizontally and vertically, like this?:

-----------
|    |    |
| 1  |  2 |
|    |    |
-----------
|    |    |
| 3  |  4 |
|    |    |
-----------
like image 396
Eddy Avatar asked Dec 11 '12 15:12

Eddy


People also ask

How do I open multiple files in Vim vertically?

Suppose you have opened a file on Vim editor and you want to split it vertically. To achieve this: Enter command mode by pressing the ESC button. Press the keyboard combination Ctrl + w , followed by the letter 'v' .

How do I open multiple files in Vim side by side?

Using windows. Ctrl-W w to switch between open windows, and Ctrl-W h (or j or k or l ) to navigate through open windows. Ctrl-W c to close the current window, and Ctrl-W o to close all windows except the current one. Starting vim with a -o or -O flag opens each file in its own split.

How do I open another window in Vim?

To open a new VIM window next to the existing one, press <Ctrl>+<w> then press <v>. You can move to the left window again by pressing <Crtl>+<w> and then pressing <h>. To open a new VIM window on the bottom of the currently selected window, press <Ctrl>+<w> then press <s>.


1 Answers

Not that elegant with -o or -O:

vim file4 -c 'split file2' -c 'vsplit file1' -c 'wincmd j' -c 'vsplit file3'
like image 146
sleepsort Avatar answered Oct 23 '22 07:10

sleepsort