There must be a way, something like this:
vim -[option] <file-list>
to open files from command prompt and not from within Vim.
- split windows vertically or/and horizontally
- in separate tabs
There must be a way, something like this:
vim -[option] <file-list>
to open files from command prompt and not from within Vim.
Ctrl+W, S (case does not matter) for horizontal splitting
Ctrl+W, v (lower case) for vertical splitting
Ctrl+W, q (lower case) to close one
Ctrl+W, Ctrl+W to switch between windows
Ctrl+W, j (or k, h, l; lowercase) to switch to adjacent window (down, up, left, right respectively)
From vim --help:
-p[N] Open N tab pages (default: one for each file)
-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
If N is provided the N windows/tabs will be opened. If N is less than the number of files in arguments, then the remaining files will be loaded in hidden buffers. If N is greater than the number of arguments, the remaining windows/tabs will be editing an empty file.
While running vim:
:sp filename for a horizontal split:vsp filename or :vs filename for a vertical split:vsplit filename is the same as :vsp filename and :vs filename, but perhaps a tiny bit easier to remember for some people
– b_dev
Sep 13 '16 at 17:14
another interested trick is the CLI -p argument - which opens them in separate tabs for recent versions of vim and gvim.
gvim -p file1.txt file2.txt
Another useful trick that I just found out, is that you can use wildcards in the filelist to open multiple files. Say you want to open file1.txt, file2.txt, and file3.txt all in separate tabs but don't feel like typing that all out you can just do:
vim -p file*
I frequently find myself needing to open a lot of files with a similar prefix, and this has been quite helpful
Ctrl-wand thenup arrowordown arrowto switch screens. – Eric Leschinski Oct 17 '12 at 01:20ctrl+w jto jump to the buffer below the current one. – mitjak Oct 04 '13 at 21:00Ctrl + WJ(down) andCtrl + WK(up) – pseyfert Nov 30 '16 at 17:02Ctrl + wleft arrow. I always usectrl + wwto cycle forward. If your on the bottom and need to access a file on the top quickly, and don't want to go forward, you need to move up first withctrl + wup arrowbefore moving left(or right). Thanks. – Brian Thomas May 11 '17 at 20:09Ctrl+WthenW, orCtrl+WthenLeft/Right Arrowworks. – schulwitz Dec 16 '21 at 00:30