How to Open Multiple Files in Vim Splits and Tabs

You can open multiple files in vim in splits and tabs.

In the examples below, I have three files in the current directory like this:

├── file1
├── file2
└── file3

Open Multiple Files in Horizontal Splits

$ vim -o file1 file2

Vim horizontal split

Open Multiple Files in Vertical Splits

$ vim -O file1 file2

In this screenshot I’ve opened three files in vertical splits:

Vim vertical splits

Open Multiple Files in Vim Tabs

Vim tabs are more powerful than tabs in other editors like VS Code, because a tab is an arrangement of panes, not a file. Each tab can contain a different layout of files. Use gt and gT to rotate through tabs. (Tip: you can move by more than one tab at a time by typing things like 2gt and 3gT.) To move tabs use :tabm (see :h tabm for documentation).

$ vim -p file1 file2

Vim tabs

Bash/Zsh Aliases

If you use fzf, these aliases are useful shortcuts:

alias v='vim `fzf`'
alias vof='vim -o `fzf`'
alias vOf='vim -O `fzf`'
alias vpf='vim -p `fzf`'

Here’s a short clip that demonstrates all the techniques above: