In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Today we are going to introduce the split-screen function of Vim.
Why do I need split screen function? In fact, there are many occasions of demand. For example, I have a big screen now, but our code is generally aligned on the left and empty on the right, so we can make full use of the screen on the right by dividing the screen. For example, I now want to view multiple documents at the same time, in addition to opening multiple terminals, we can also split the screen to achieve our goal.
Of course, there are many similar occasions, as long as we dig fully, we will certainly be able to dig out more demand.
Next, we will introduce the split screen operation of Vim in detail.
Basic operation of split screen function
First of all, let's open a random code file. For demonstration purposes, the longer the code, the better.
Vim test.c
Now let's divide the interface into left and right parts. First we press ctrl+w, followed by v. After doing this, the screen is split in two, as shown below:
What do we do if we want to divide into three parts? Very simply, on the basis of the above, we perform the above operation again, and the screen will be divided into three parts.
If you find this too troublesome, we can also achieve the same effect by executing the following command in the last line mode:
: vsplit
Since it's an order, there must be an acronym:
: vsp
It's ridiculously simple. Let's start from scratch. This time we will split the screen horizontally. First, let's run the following command in the last line mode:
: split
Similarly, we also have abbreviated commands:
: sp
This function can also be achieved through keyboard key combinations. For split horizon, press ctrl + w and then s. Again, all these letters are lowercase and are in the English input state.
Switch between screens
As mentioned earlier, split view is very useful in many scenarios, but if you can't switch from one split to another, then this split view is completely meaningless. Let me show you how to switch from one split to another.
Here, I set up four split views of the same file.
At the beginning, the cursor is at the first split screen. Now, if we want to switch to the right split screen, we need to press ctrl + w and then l.
Similarly, if we want to switch to the left window, we need to press ctrl + w and then h.
If you split the screen horizontally, you can only move the cursor up and down. To switch to the split screen above, press ctrl + w and then k.
Similarly, if you want to switch to the split screen below, you need to press ctrl + w and then j.
Edit under different split screens
So far, I believe you have learned how to split the screen. So after dividing the screen, how can we edit the text under these split screens? In fact, each split screen can be regarded as a complete Vim window, how we usually edit, how to edit the document.
Copy and paste operation
There is basically no difference between unsplit screen and unsplit screen, you can copy a piece of text from one split screen, and then switch to another split screen to paste. The operation is all the same, but you just need to switch between different screens.
Change the split screen size
By default, Vim splits the screen on an equal basis. What if we want to maximize / minimize a split screen?
If you want to widen the current window to the maximum size, press ctrl + w, and then press | (Note: it is not lowercase L, the and / or non-and |).
If you want to increase the height of the current window to the maximum size, you need to use ctrl + w, and then use *.
So if you want to resize all split windows, use ctrl+w and press =.
By default, when Vim splits, each split is equal in width or height. To customize the width of the split screen, you can use the following structure:
: vsp
Similarly, for split horizon, you can customize the height using a similar structure:
Sp opens several different files under the same Vim window
So far, all Vim splits are copies of the same file, but in many cases, we need to open multiple different files. We can split the Vim window and open different files in different screens.
How do I open a new file in Vim? We can use the following command:
: e/filename.extension
For example, if we want to open vimrc in a completely new Vim instance, we can use the following command:
: e~/.vimrc
After opening vimrc, we want to split the screen horizontally and open a new file, using the following command:
: sp
For vertical split screens, a similar structure is used:
Summary of vsp
Vim split-screen talk is coming to an end with you. This kind of operation is still interesting and very practical.
This paper introduces some basic operations and editing methods of Vim screen splitting. Rational use of this function can make us use the computer screen more efficiently and improve our efficiency.
These are the details of the split screen operation (picture and text) of the Vim editor, please pay attention to other related articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.