Table of Contents
在不同分屏下进行编辑
Home Operation and Maintenance Linux Operation and Maintenance Vim editor split-screen operation (graphics and text)

Vim editor split-screen operation (graphics and text)

Nov 30, 2019 pm 03:57 PM
vim split-screen

Vim editor split-screen operation (graphics and text)

Today we will introduce the split screen function of Vim.

Why do you need the split screen function? In fact, there are many demand occasions. For example, my current screen is very large, but our code is generally left-aligned and the right side is empty, so that we can make full use of the right screen by splitting the screen. For another example, I now want to view multiple documents at the same time. In addition to opening multiple terminals, we can also achieve our goal through split screen.

Of course there are many similar situations. As long as we fully explore, we will definitely be able to find more needs.

Let’s introduce Vim’s split-screen operation in detail.

Recommendation: [Linux Video Tutorial]

Basic operation of split-screen function

First we open a code file at random. For ease of demonstration, the longer the code length, the better.

vim test.c
Copy after login

Now let us divide the interface into left and right parts. First we press ctrl w, followed by v. After doing this, the screen will be divided into two, as shown below:

Vim editor split-screen operation (graphics and text)

What if we want to divide it into three equal parts? It's very simple. Based on the above, if we perform the above operation again, the screen will be divided into three equal parts.

Vim editor split-screen operation (graphics and text)

If you think this operation is too troublesome, we can also achieve the same effect by executing the following command in the last line mode:

:vsplit
Copy after login

Vim editor split-screen operation (graphics and text)

Vim editor split-screen operation (graphics and text)

Since it is a command, it must have an abbreviation:

:vsp
Copy after login

It’s so simple that it’s ridiculous... Let’s start from the beginning. Let’s start from the beginning. This time we split the screen horizontally. First we run the following command in last line mode:

:split
Copy after login

Vim editor split-screen operation (graphics and text)

Vim editor split-screen operation (graphics and text)

## Similarly, we also have the abbreviated command:

:sp
Copy after login

This function can also be achieved through keyboard key combinations. For horizontal splitting, press

ctrl w ​​first, then s. Again, all of these letters are in lowercase and in English.

Vim editor split-screen operation (graphics and text)

Switching between split screens

As mentioned before, split screen is very useful in many scenarios, but if you Without the ability to switch from one split screen to another, this split view is completely pointless. Let me show you how to switch from one split screen to another.

Here, I set up 4 split views of the same file.

Vim editor split-screen operation (graphics and text)

At the beginning, the cursor is on the first split screen. Now, if we want to switch to the right split screen, we need to press

ctrl w ​​first, and then l.

Vim editor split-screen operation (graphics and text)

Vim editor split-screen operation (graphics and text)

Vim editor split-screen operation (graphics and text)##Similarly, if we want to switch to the left window, we need to press ## first #ctrl w

​​and then

h.

Vim editor split-screen operation (graphics and text)

#If you split the screen horizontally, you can only move the cursor up and down. To switch to the split screen above, you need to first press Vim editor split-screen operation (graphics and text)ctrl w

​​and then

k.

Vim editor split-screen operation (graphics and text)

##Similarly, if you want to switch to the split screen below, you need to press

ctrl wVim editor split-screen operation (graphics and text) ​​first , then press

j

.

在不同分屏下进行编辑

到此为止,我相信大家已经学会了怎么进行分屏操作了。那分完屏,我们怎么在这些分屏下进行文本编辑呢?其实,每个分屏都可以视为一个完整的 Vim 窗口,我们平常怎么编辑的,就怎样去编辑文档。

Vim editor split-screen operation (graphics and text)

复制及粘贴操作

与未分屏是基本无差的,大家可以在从一个分屏里复制一段文本,再切换到另一个分屏进行粘贴。操作都是一样的,只是需要在不同分屏里切换而已。

Vim editor split-screen operation (graphics and text)

改变分屏尺寸

默认情况下,Vim 是按等分进行分屏操作的。如果我们想最大化/最小化某个分屏,要如何操作?

如果要将当前窗口加宽到最大尺寸,需要先按 ctrl + w ,然后按 |(注意:不是小写 L ,是与或非的那个与 | )。

如果你想把当前窗口高度加高到最大尺寸,那么需要使用 ctrl + w ,然后使用 **_** 。

那如果想要重置所有分割窗口的大小,那么使用 ctrl+w ,然后按 =

默认情况下,Vim 在进行分屏操作时,每个分屏是等宽或等高的。如果要自定义分屏的宽度,大家可以使用以下结构:

:<width> vsp
Copy after login

同样地,对于水平分割而言,可以使用类似结构自定义高度:

:<height> sp
Copy after login

在同一个 Vim 窗口下打开多个不同文件

目前为止,所有的 Vim 分屏都是同一个文件的副本,但在很多情况下,我们需要打开多个不同的文件。我们可以将 Vim 窗口进行分屏,再在不同的分屏里打开不同的文件。

如何在 Vim 中打开一个新文件?我们可以使用以下命令:

:e<path_to_file>/filename.extension
Copy after login

例如,我们想要在一个全新的 Vim 实例中打开 vimrc,我们可以使用以下命令:

:e~/.vimrc
Copy after login

打开 vimrc 之后,我们想要将屏幕水平切分并打开一个新文件,可以使用以下命令:

:sp<file_path>
Copy after login

而对于垂直分割屏幕,使用的也是类似的结构:

:vsp<file_path>
Copy after login

小结

Vim 分屏讲到这里就要跟大家告一段落了。这种操作还是比较有趣,并且十分实用。

本文介绍了 Vim 分屏的一些基本操作及编辑方法,合理利用这个功能可以使我们更加高效使用电脑屏幕,提高我们的效率。

本文来自php中文网,linux系统教程栏目,欢迎学习!

The above is the detailed content of Vim editor split-screen operation (graphics and text). For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to split screen on oppo phone How to split screen on oppo phone Mar 30, 2024 pm 02:41 PM

1. Click the square-shaped multi-function key in the virtual navigation key at the bottom of the phone screen. 2. After entering the background application card, select the application card that needs to be split screen and drag it down. 3. Click [Split Screen] on the upper right side of the card. 4. After entering the following page, we can click in the small box at the bottom of the screen to open another application that requires split screen. 5. Drag the slider in the middle to adjust the page size of the split-screen application, or drag it to the top of the screen to exit split-screen.

How to split screen on Redmi 13c? How to split screen on Redmi 13c? Mar 04, 2024 pm 11:50 PM

Redmi13C is a new model that is currently attracting much attention, and its performance configuration is very powerful. Since its launch, sales have remained at a good level, and many users are confused about how to perform split-screen operations on Redmi 13C. Next, let’s introduce it in detail! How to split screen on Redmi 13c? To open two apps at the same time, first open one app and then tap the Recent Apps button at the bottom of your phone's screen. This will display a list of recently used applications. Then select the second app from the list and tap to open it. This allows you to run two applications simultaneously and switch between them. 2. Enter split-screen mode: long press the "Recent Tasks" button on the second open application. This will display a popup on the screen

How to split screen on Xiaomi phone How to split screen on Xiaomi phone Mar 01, 2024 pm 10:40 PM

How to split screen on Xiaomi mobile phone? You can split screen on Xiaomi mobile phone to use multiple software at the same time, but most users don’t know how to turn on the split screen function. Next is the graphic tutorial on how to split screen on Xiaomi mobile phone brought by the editor. Interested users come and take a look! How to split screen on a Xiaomi phone 1. First open the [Settings] function in the Xiaomi phone, and then click [More Settings] on the Settings function page; 2. Then on the More Settings page, select [Gestures and Key Shortcuts]; 3. Then on the function page shown in the figure below, click the [Enter Split Screen] option; 4. Finally, select the split screen button according to your needs and habits. Once the selection is completed, you can set the split screen mode on the desktop.

How to split screen two apps on Xiaomi Mi 14? How to split screen two apps on Xiaomi Mi 14? Mar 18, 2024 pm 10:43 PM

Among the functions of mobile phones, the split-screen function is undoubtedly a very practical feature. As a powerful smartphone, Xiaomi Mi 14 naturally has this convenient split-screen function. Through the split-screen function of Xiaomi 14, we can run two applications at the same time, which greatly improves our work efficiency and entertainment experience. So, how to split screen two applications on Xiaomi Mi 14? How to split the screen into two applications on Xiaomi Mi 14 1. We swipe up on the homepage interface to open the task interface. 2. Then long press the software you want to split screen in the task interface to enter the new interface. 3. Click on the two rectangular icons on the right to enter the split-screen interface. 4. Then we enter split screen. Overall, the split-screen function of Xiaomi Mi 14 is very simple and easy to use, no matter how many

How to split screen on vivo mobile phone Detailed explanation: Introduction to split screen tutorial on vivo mobile phone How to split screen on vivo mobile phone Detailed explanation: Introduction to split screen tutorial on vivo mobile phone Mar 20, 2024 pm 03:31 PM

When we are watching a TV series and want to chat with our friends, but it is too troublesome to switch applications back and forth, we can use the split-screen function of the mobile phone. How to split screen on vivo phone? I believe many friends are very curious. Li Jinjin has compiled a detailed tutorial for everyone below. Call your friends to take a look! Introduction to split-screen tutorial on vivo mobile phones 1. Click Settings-Shortcuts and Assistance-Split-screen Multitasking-Manual Split Screen, and turn on [Three-finger slide up to split screen]. 2. Swipe up with three fingers on the application interface that requires split screen to enable split screen, and then click on the second application. You can also scroll down on the phone screen to find the &quot;Split Screen&quot; button in the shortcut center and click to turn it on. Or click on the list icon in the upper right corner of the multitasking interface and click the &quot;Split Screen&quot; button to turn it on.

What is the shortcut key for split screen in Windows 7 computer? What is the shortcut key for split screen in Windows 7 computer? Jul 09, 2023 pm 10:57 PM

Many users want to know what is the shortcut key for split screen in Windows 7. Users can press the shortcut key Win+P to open the projection window, and then select the type of split screen. You can choose to copy or expand, and choose according to the requirements. After selection, you can set the screen resolution and so on, so our Windows 7 computer split-screen shortcut key is Win+P. Introduction to split-screen shortcut keys for windows 7 computer 1. Use the shortcut key combination "Win+P" on the keyboard to pop up the projection window 2. You can choose whether the second screen is expanded or copied. Copying means that the two screens display the same content, and expanding is Add the second monitor as the first display 3. At this time, just select "Copy". After setting up, click on the desktop

How to split screen on iPad How to split screen on two apps on iPad How to split screen on iPad How to split screen on two apps on iPad Feb 22, 2024 pm 04:13 PM

Click Home Screen and Dock in Settings, enable multiple APP functions in Multitasking, swipe up and select the app and drag to any side of the screen to split the screen. Applicable models of this tutorial: iPad Pro System: iPadOS15.3 Analysis 1 Enter Settings and click on the Home Screen and Dock option, then click on the Multitasking option on the right side of the page. 2. After entering the multitasking page, turn on the button that allows multiple APPs and gestures. 3. Swipe up from the bottom of the screen and select the split-screen application. Drag to any side of the screen to split the screen. Supplement: How to enable picture-in-picture on iPad 1. First, click on the desktop to enter settings. 2After entering the settings page, click the Home Screen and Dock option. 3 Then click on the multitasking option. 4In the new interface, click to turn on picture-in-picture. 5Finally

How to add the Escape key to your iPad keyboard How to add the Escape key to your iPad keyboard Apr 16, 2023 pm 01:43 PM

How to Remap CapsLock to ESC on iPad Keyboard Are you ready to make CapsLock the ESC key on your iPad? Here's all you need to do: Open the Settings app on your iPad Go to "General" then go to "Keyboard" Go to "Hardware Keyboard" Select "Modifier Keys" Select "CapsLockKey" and select "Escape" as Modifier Keys Now you're ready to try out the new hardware ESC key on your iPad by pressing CapsLock. Go to any application that uses the Escape key and you can test it immediately, such as vi/vim. Now you can use a physical keyboard from

See all articles