How To Use VIM Split Screen

28/12/2020
VIM is a very popular terminal based text editor. Using VIM is a little bit trickier than other text editors. In this article I will show you how to work with VIM split screens with keyboard shortcuts. Let’s get started.

Installing VIM

VIM text editor is available on the official package repository of almost all Linux distributions such as CentOS, RHEL, OpenSUSE, Ubuntu, Debian, Linux Mint etc.

For Debian Based Operating Systems

On Ubuntu, Debian, or Linux Mint, run the following command to install VIM if you don’t have it yet.

$ sudo apt-get update
$ sudo apt-get install vim -y

VIM should be installed.

For RPM Based Operating Systems

On RHEL, CentOS, or Fedora, run the following command to install VIM:

$ sudo yum install vim -y

Basics of VIM

Once VIM is installed, you can start VIM with the following command:

$ vim

This is the welcome screen of VIM text editor.

VIM has many modes. The most important ones are “Command Mode” and “Insert Mode”. When VIM starts, you’re in “Command Mode”. In this mode, you run VIM commands to open file, save file, close VIM, search substrings in file and many more.

You can press ‘i’ to switch to “Insert Mode”. In this mode, VIM works like any other text editor.  You can press <ESC> to go back to “Command Mode” from “Insert Mode”.

Opening a File on VIM

To open a file on VIM, you go to the “Command Mode” and then type the following command to open a file.

:open FILE_PATH

FILE_PATH can be relative path to the directory where you opened VIM from or full path.

Splitting VIM screen Horizontally and Vertically

To open a new VIM window next to the existing one, press <Ctrl>+<w> then press <v>.

Now you can move to the right window from the left by pressing <Ctrl>+<w> and then pressing <l>

You can move to the left window again by pressing <Crtl>+<w> and then pressing <h>.  To open a new VIM window on the bottom of the currently selected window, press <Ctrl>+<w> then press <s>.  You currently selected window should be split vertically as shown in the screenshot below.

You can go to the window below the selected window by pressing <Ctrl>+<w> and then pressing <j>

You can go to the window above the selected window by pressing <Ctrl>+<w> and then pressing <k>

Copy and Paste Texts Between VIM Split Screens

I have 3 different text files opened in 3 different windows on VIM as you can see from the screenshot.

Let’s say I want to copy the text “good text editor” to another VIM window.

To do that, from the “Command Mode”, first go to the location from where you want to start your selection and press <v> to go to the “Visual Mode” of VIM and select the substring and press <y>. The text should be copied.

Now go to another window by pressing <Ctrl>+<w> and then any of <h> <j> <k> or <l> depending on your choice. Now go to “Insert Mode” by pressing ‘i’ and navigate to the place where you want to paste the text. Then go back to “Command Mode” by pressing <ESC> and press <p> to paste the copied text.

You can see from the screenshot below that the copied text is pasted correctly.

Change the Split Screen Window Size of VIM

There are several shortcuts to change the split screen window size of VIM.  You can increase the width of your window by pressing <Ctrl>+<w> and then ‘>’ and decrease the width by pressing <Ctrl>+<w> and then ‘<’.

This is how my VIM window looks now.

After increasing the width, this is how it looks like now:

You can also increase or decrease the height of your VIM window. To increase the height of your window, press <Ctrl>+<w> and then press ‘+’ and to decrease the width press <Ctrl>+<w> and then press ‘-’.

After increasing the height one of my VIM window, this is how it looks like now:

You can reset to the equal width and height windows by pressing <Ctrl>+<w> and then pressing ‘=’ as you can see from the screenshot below.

That’s how you use VIM shortcut keys to use VIM split screen feature, navigate between them, resize them and copy/paste between windows. Thanks for reading this article.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

How to Install Skype on Manjaro Linux

Skype is one of the most popular communication platforms that offer such a great service for free! In fact, it’s one...
29/12/2020

Check proxy trên trang nào chuẩn nhất❓

Sau khi mua được proxy rồi thì không thể thiếu bước check chất lượng IP. Hiện nay có rất nhiều...
01/11/2023

PRIVATE PROXY LÀ GÌ? MUA PRIVATE PROXY Ở ĐÂU?

DỊCH VỤ THUÊ PROXY PRIVATE DEDICATED ONET IDC cung cấp dịch vụ IP Proxy Private giúp quý khách sử dụng...
13/11/2022
Bài Viết

Bài Viết Mới Cập Nhật

Mua Proxy V6 Nuôi Facebook Spam Hiệu Quả Tại Onetcomvn
03/06/2024

Hướng dẫn cách sử dụng ProxyDroid để duyệt web ẩn danh
03/06/2024

Mua proxy Onet uy tín tại Onet.com.vn
03/06/2024

Thuê mua IPv4 giá rẻ, tốc độ nhanh, uy tín #1
28/05/2024

Thuê địa chỉ IPv4 IPv6 trọn gói ở đâu chất lượng, giá RẺ nhất?
27/05/2024