在 VIM 中打开一个缓冲区作为垂直分割 [英] Open a buffer as a vertical split in VIM

查看:22
本文介绍了在 VIM 中打开一个缓冲区作为垂直分割的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果你在 VIM 中编辑一个文件,然后你需要打开一个现有的缓冲区(例如从你的缓冲区列表::buffers)你怎么能在垂直拆分中打开它?

If you are editing a file in VIM and then you need to open an existing buffer (e.g. from your buffer list: :buffers) how can you open it in a vertical split?

我知道您已经可以使用普通分割打开它,例如:

I know that you already can open it with a normal split like:

:sbuffer N

这里 N 是您想要的缓冲区编号,但是,上面的内容会水平而不是垂直地打开 N 缓冲区.

Wehere N is the buffer number you want, however, the above opens that N buffer horizontally, not vertically.

我也知道您可以在打开后更改窗口位置并进行垂直拆分,如下所示:

I'm also aware that you can change the window placement after opening and have a Vertical Split like so:

Ctrl-W H
Ctrl-W L

这将垂直地向右或向左拆分窗口.

Which will vertically split the window to the right or the left.

在我看来,如果有 sbuffer 应该有一个 vsbuffer 但它不存在(我不知道)

It seems to me that if there is a sbuffer there should be a vsbuffer but that doesn't exist (not that I am aware of)

另外,请注意,我不是在寻找解决这个问题的插件.我知道有很多插件可以让您做到这一点.

Also, please note that I am not looking for a plugin to solve this question. I know about a wealth of plugins that will allow you to do this.

我确定我可能遗漏了一些已经存在的东西.

I am sure I might be missing something that is already there.

本着最好的协作精神,如果其他人偶然发现这个问题并且不想安装插件,我已经创建了一个带有映射的简单函数:

In the best spirit of collaboration, I have created a simple Function with a Mapping if someone else stumbles across this issue and do not want to install a plugin:

功能:

" Vertical Split Buffer Function
function VerticalSplitBuffer(buffer)
    execute "vert belowright sb" a:buffer 
endfunction

映射:

" Vertical Split Buffer Mapping
command -nargs=1 Vbuffer call VerticalSplitBuffer(<f-args>)

这完成了在右拆分中打开缓冲区的任务,因此对于缓冲区 1,您可以这样称呼它:

This accomplishes the task of opening a buffer in a right split, so for buffer 1, you would call it like:

:Vbuffer 1

推荐答案

尝试:

:vert sb N

这将打开左垂直拆分(默认情况下,除非您修改了某些选项).

which will open a left vertical split (by default, unless you have modified some options).

另一方面,要打开右侧的拆分:

To open a split to the right, on the other hand:

:vert belowright sb N

这篇关于在 VIM 中打开一个缓冲区作为垂直分割的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆