Home Vim Editor Tips How to Split Vim Workspace Vertically or Horizontally

How to Split Vim Workspace Vertically or Horizontally

There is no better computing environment than the one availed by a Linux operating system distribution. This operating system environment gives its users a complete computing experience without too much interaction with the GUI (Graphical User Interface). The more experienced you are with Linux the more time you spend on the Linux command-line environment.

The command-line environment is efficient enough to handle OS-centered tasks like file editing, configuration, and scripting. A command-line text editor like the Vim editor makes it possible to perform such tasks.

Popular Vim Features

Vim is a text manipulation program that is enriched with the following features:

  • Has a very low memory footprint making it resource-friendly.
  • Its command centric making it possible to achieve complex text-related tasks via execution of Vim-related commands.
  • Vim is highly configurable due to the simplicity behind the storage of its main configurations.
  • Supports numerous plug-ins which make it easy to extend its functionality.
  • Supports multiple windows and buffers.
  • You can also work on multiple files via multiple tabs.
  • Users can repeatedly record and play vim commands via its recording features.

Vim is also an open-source and cross-platform text editor which makes its installation possible on multiple operating system environments. Its vintage nature as a popular and one of the oldest text editors led to the creation of a large and growing Vim community where new users can learn from the expertise of experienced users.

Install Vim Editor in Linux

This article guide assumes that you have the Vim text editor installed on your Linux operating system distribution. If not, reference the following installation guide:

$ sudo apt install vim            [On Debian, Ubuntu and Mint]
$ sudo yum install vim            [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux]
$ sudo emerge -a app-editors/vim  [On Gentoo Linux]
$ sudo pacman -S vim              [On Arch Linux]
$ sudo zypper install vim         [On OpenSUSE]    

Splitting Vim Workspace Vertically or Horizontally

Supposing we have a file called vim_demo opened under the Vim text editor.

$ vim vim_demo.txt
View File in Vim
View File in Vim

With this file open, our aim is to have better productivity by splitting the current Vim workspace into multiple vertical or horizontal windows. The first step is to ensure that your Vim workspace is in command mode by pressing the [Esc] keyboard key.

Splitting Vim Workspace Vertically

To split the above workspace vertically, execute the vim command:

:vsplit 
Split Vim Workspace Vertically
Split Vim Workspace Vertically

To create a more vertical workspace, re-execute the above command.

The files you open on Vim’s vertical workspace do not have to be identical. To have a different file open on the vertical workspace, implement the command:

:vsplit path/to/file
Open File Vertically in Vim
Open File Vertically in Vim

Splitting Vim Workspace Horizontally

To split the Vim workspace horizontally, we would implement the following command:

:split
Split Vim Workspace Horizontally
Split Vim Workspace Horizontally

To split different files horizontally, implement the command.

:split /path/to/file
Open File Horizontally in Vim
Open File Horizontally in Vim

You can even combine the vertical splitting and horizontal splitting vim commands and work with both vertical and horizontal Vim workspace.

Combine Vertical and Horizontal Split in Vim
Combine Vertical and Horizontal Split in Vim

Managing Vertical/Horizontal Vim Workspace Windows

The current window (the one with a blinking cursor) can be closed with the vim command :q .

On vertically split Vim workspace:

  • To navigate to the left window use [Ctrl]+[w]+[h] keyboard keys combination.
  • To navigate the right window use [Ctrl]+[w]+[i] keyboard keys combination.

On horizontally split Vim workspace:

  • To navigate to the bottom window use [Ctrl]+[w]+j keyboard keys combination.
  • To navigate to the top window use [Ctrl]+[w]+k keyboard keys combination.
  • The keyboard keys combination [Ctrl]+[w] and pressing [+] key increase the current window’s height.
  • The keyboard keys combination [Ctrl]+[w] and pressing [-] key reduce the current window’s height.
  • The keyboard keys combination [Ctrl]+[w] and pressing [>] key increase the current window’s width.
  • The keyboard keys combination [Ctrl]+[w] and pressing [<] key reduce the current window’s width.
  • The keyboard keys combination [Ctrl]+[w] and pressing [=] key reset all split windows’ sizes to be equal.

We can now comfortably work with vertical and horizontal workspace in Vim. Your comments and feedback are always appreciated.

Ravi Saive
I am an Experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies. Founder of TecMint.com, LinuxShellTips.com, and Fossmint.com. Over 150+ million people visited my websites.

Each tutorial at UbuntuMint is created by a team of experienced writers so that it meets our high-quality standards.

Was this article helpful? Please add a comment to show your appreciation and support.

Got something to say? Join the discussion.

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published or shared. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.