How to open files in vertically/horizontal split windows in Vim from the command line

Ctrl+W, S (upper case) for horizontal splitting

Ctrl+W, v (lower case) for vertical splitting

Ctrl+W, Q to close one

Ctrl+W, Ctrl+W to switch between windows

Ctrl+W, J (xor K, H, L) to switch to adjacent window (intuitively up, down, left, right)


I'm assuming you mean from the command line. From vim --help:

-o[N]                Open N windows (default: one for each file)
-O[N]                Like -o but split vertically

So type this to open files split horizontally, for example:

vim -o file1.txt file2.txt file3.txt

While running vim:

  1. :sp filename for a horizontal split
  2. :vsp filename or :vs filename for a vertical split