How to Split Vim Screen Horizontally and Vertically in Linux

Vim text editor, short for Vi IMproved, is one of the most powerful and popular Linux text editors that enjoys immense patronage from the open-source community. It is an improvement of the vi editor and uses a combination of regular keyboard keys to provide vast functionality.

Vim provides colored syntax among other basic functionalities such as inserting and deleting text, copying and pasting text, and saving changes made to a file. The list of what you can do is quite long and the learning curve is steep.

In this guide, we endeavor to show you various ways that you can split the Vim editor into different workspaces in the Linux command-line.

Installing Vim in Linux

Before we proceed, ensure that Vim is installed on your system. Also, this guide is intended for users running a system with a graphical display so as to observe the split effect of the vim editor on the terminal.

To install vim, run the following commands:

$ sudo apt install vim      [On Debian, Ubuntu & Mint]
$ sudo yum install vim      [On RHEL, CentOS & Fedora]
$ sudo pacman -Sy vim       [On Arch & Manjaro]
$ sudo zypper install vim   [On OpenSUSE]

Running the vim command without any arguments displays basic information about the Vim editor including the version and basic commands such as how to get help and exit the text editor as shown below.

$ vim
Start Vim Editor
Start Vim Editor

Splitting Vim Screen Vertically

Suppose you have opened a file on Vim editor and you want to split it vertically. To achieve this:

  • Enter command mode by pressing the ESC button.
  • Press the keyboard combination Ctrl + w, followed by the letter ‘v’.

You will get a split-screen shown below.

Splitting VIM Screen Vertically
Splitting VIM Screen Vertically

To navigate to the right pane, press Ctrl + w, followed by the letter ‘l’.

Navigate VIM Screens
Navigate VIM Screens

To head back to the left pane, use the combination Ctrl + w, followed by the letter ‘h’.

Splitting Vim Screen Horizontally

To split the vim screen horizontally, or open a new workspace at the bottom of the active selection, press Ctrl + w, followed by the letter ‘s’. In the example below, the left section has been split into two workspaces.

Splitting VIM Screen Horizontally
Splitting VIM Screen Horizontally

To navigate to the bottom section hit Ctrl + w, followed by the letter ‘j’.

Navigate to Bottom VIM Screen
Navigate to Bottom VIM Screen

To head back to the upper section, press Ctrl + w, followed by the letter ‘k’.

Navigate to Upper VIM Screen
Navigate to Upper VIM Screen

Increase Width of Vim Current Workspace

To increase the width of your current selection on the Vim editor, press Ctrl + w, and shortly followed by the SHIFT + ‘>’ combination.

In the example below, I have increased the width of the left pane.

Increase Vim Workspace Width
Increase Vim Workspace Width

To reduce the width of your current Vim selection, press Ctrl + w, and then SHIFT + ‘<’ combination.

In the screenshot below, you can clearly see that the left section has reduced in width.

Reduce Vim Workspace Width
Reduce Vim Workspace Width

Increase Height of Vim Current Workspace

To increase the height of your current workspace, use the combination press Ctrl + w, followed by SHIFT + ‘+’ combination. The illustration below shows

Increase Vim Workspace Height
Increase Vim Workspace Height

To decrease the height of the workspace, press Ctrl + w, followed by the - (minus) sign.

Decrease Vim Workspace Height
Decrease Vim Workspace Height

To ensure the height of the upper and lower workspaces is equal press Ctrl + w, followed by the = (equals) sign.

Set Equal Sizes of Vim Workspace
Set Equal Sizes of Vim Workspace

And that’s how you can split the Vim screen into various spaces.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

James Kiarie
This is James, a certified Linux administrator and a tech enthusiast who loves keeping in touch with emerging trends in the tech world. When I'm not running commands on the terminal, I'm taking listening to some cool music. taking a casual stroll or watching a nice movie.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

7 Comments

Leave a Reply
    • It’s not about having the same buffer in both windows. Once you’ve split into two windows you can now switch to another buffer in one of the windows and use, for example, the two windows to see the differences between two similar source code files.

      Reply
  1. Good tips. Something I knew existed, but haven’t really made use of. This could be really handy for large files.

    Something to fix in the article:

    “To navigate to the right pane, press Ctrl + w, followed by the letter ‘v’.”

    ….should be:

    To navigate to the right pane, press Ctrl + w, followed by the letter ‘l’.

    Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.