Open In App

How to Split Vi Screen Horizontally and Vertically in Linux

Last Updated : 09 Oct, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will cover how to split the vi editor screen horizontally and vertically in Linux along with the command syntax and example, but first, we look at what is vi editor followed by screen splitting in vi editor along with examples and screenshots followed by resizing of windows/panels in the editor.

Linux

Linux was developed by Linus Torvalds in 1991 as a hobby project. It is an open-source (source code that can be used by anyone freely) kernel that is most popular and widely used in the industry as well as in personal systems. There are various operating systems based on the Linux kernel, some of the popular Linux distributions are Ubuntu, Cent OS, Red Hat, Debian, and Kali Linux.

VI Editor

Vi Editor is a widely used text editor in Unix/Linux systems and is known for its efficiency and flexibility. Vi editor was developed in 1976 by Bill Joy and later in 1991, an improved version of Vi editor was released which is known as VI IMproved (VIM). There are two modes in the vi editor:

  • insert mode
  • command mode

Split Screen Horizontally in vi editor

To split the screen horizontally follow the below steps,

  • If you are in insert mode Press Esc to enter command mode and run the below command

:split filename

or

:sp filename

  • Alternatively, you can press the keyboard combination ‘Ctrl + w’ and then press ‘s‘ to achieve the same result.
  • This will split the screen into two sections horizontally, to Toggle between the workspaces use Ctrl+w+w

vi hortizontal split

  • ‘Ctrl+w’ followed by t or b switch to the top (first) or bottom (last) window
  • To Toggle between the workspaces use the following commands. To navigate to the top pane and bottom pane respectively use the following key bindings.
  • CTRL + w + k – Navigate to the top pane.
  • CTRL + w + j – Navigate to the bottom panel

Split Screen Vertically in vi editor

To split screen vertically follow the below steps:

  • If you are in insert mode Press Esc to enter in command mode and run the below command

:vsplit filename

or

:vs filename

  • Alternatively you can press the keyboard combination ‘Ctrl + w’ and then press ‘v’ to achieve the same result.
  • This will split screen into two sections vertically to Toggle between the workspaces use Ctrl+w+w

vi vertical split

  • To Toggle between the workspaces use the following commands. To navigate to the left pane and right pane respectively use the following key bindings.

Ctrl + w + h – To navigate to left panel

Ctrl + w + l – To navigate to right panel

Resizing window/panels

To resize the panel we can use the resize command in vi editor which command is as follows:

:resize [size as number]

Example – :resize 5

resize window panel

Conclusion

In this article, we had covered how to split the screen horizontally and vertically in vi editor along with the screenshots and how to nagivate in to panels and toggling options avaialable, followed by resizing of windows/panels in the editor.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads