Barbarian Meets Coding


Boost Your Coding Fu With VSCode and Vim
Chapter 14.Table of ContentsCheatsheet

Splits, Tabs and Switching Between Them

A great feature in Vim is its great support for splits and tabs. Creating, resizing, rearranging and moving between splits and tabs is incredibly easy and fast in Vim. VSCodeVim offers an OK ok-support support for this Vim feature that, although not as good as Vim’s, is still useful.


Splits are awesome. They allow you to divide your workspace into vertical and horizontal split windows:

  • Use the :sp {relative-path-to-file} command to open a file in a horizontal split.
  • Use the :vsp {relative-path-to-file} command to open a file in a vertical split.

Alternatively, instead of these Ex commands you can use:

  • <CTRL-W> S to open horizontal split (mnemonic Window and Split).
  • <CTRL-W> V to open a vertical split (mnemonic Vertical).

Using either of these commands will open a split to the same file that you’re currently editing. So after creating the split, you’ll need to type CMD-P on Mac or CTRL-P on Windows/Linux to open a new file in that split.

Window splitting in Vim

You can move between splits using with CTRL-W + hjkl. Are you currently on a vertical split and want to move to the one on the right? Type CTRL-W then l (the motion you typically use to move the cursor to the right). Makes sense, doesn’t it? This key combination works even when jumping from a code window to the file explorer or an integrated terminal. Sweet!


In Visual Studio Code you can open several tabs within a split. In order to do so:

  • Use :tabnew {file} to open a file in a new tab
  • Use :tabn (:tabnext) to go to the next tab
  • Use :tabp (:tabprevious) to go to the previous tab
  • Use :tabo (:tabonly) to close all other tabs

There are some additional Ex commands to work with tabs but these ones are definitely the most useful ones.

  1. Vim works with tabs of splits, whereas VSCode works with splits of tabs. I find the former much better to work with than the latter. Within Vim a tab can denote a feature or workspace, whereas splits within a tab correspond to a related piece of functionality. In my opinion, this is a much better mental model and way of working.

Jaime González García

Written by Jaime González García , Dad, Husband, Front-end software engineer, UX designer, amateur pixel artist, tinkerer and master of the arcane arts. You should follow him on Twitter where he shares useful stuff! (and is funny too).Jaime González García