Open Files Side-By-Side with Vim

I’ll often want to open a couple of files in Vim and then split the main window so I have one file on the left, and one file on the right. I’ve just learnt that you can tell Vim to open each in it’s own split, a vertical split or a horizontal split.

# Vertical split:
vim -O <file1> <file2>

# Horizontal split:
vim -o <file1> <file2>

It works with more than one file as well, so you could open three files, and have a pane for each.

About

I'm a technology professional who's been passionate about computers since my Grandad introduced me to an Intel 386 back in the 90s when I was a kid. Those moments inspired a passion within for technology, and I've been playing around with anything with a circuit board ever since. Whenever I have a moment you can probably find me working on something computer-related, and this is where I like to write about those moments.