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
5 Answers
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 verticallySo type this to open files split horizontally, for example:
vim -o file1.txt file2.txt file3.txt 6 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)
8While running vim:
:sp filenamefor a horizontal split:vsp filenameor:vs filenamefor a vertical split
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
1