像缓冲区一样使用 Vim 的选项卡 [英] Using Vim's tabs like buffers

查看:33
本文介绍了像缓冲区一样使用 Vim 的选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我研究了在 Vim 中使用选项卡的能力(使用 :tabe:tabnew 等)来替代我目前拥有许多文件的做法在隐藏缓冲区中的同一窗口中打开.

I have looked at the ability to use tabs in Vim (with :tabe, :tabnew, etc.) as a replacement for my current practice of having many files open in the same window in hidden buffers.

我希望我打开的每个不同的文件总是在它自己的标签中.然而,有一些事情会阻碍这一点.我该如何解决这些问题:

I would like every distinct file that I have open to always be in its own tab. However, there are some things that get in the way of this. How do I fix these:

  1. 当诸如 gf^] 之类的命令跳转到另一个文件中的某个位置时,该文件会在当前选项卡的新缓冲区中打开.有没有办法让所有这些类型的命令在新选项卡中打开文件,或者如果文件已经打开,则切换到包含文件的现有选项卡?

  1. When commands like gf and ^] jump to a location in another file, the file opens in a new buffer in the current tab. Is there a way to have all of these sorts of commands open the file in a new tab, or switch to the existing tab with the file if it is already open?

切换缓冲区时我可以使用:b <文件名的一部分>它将完成现有缓冲区中文件的名称.<文件名的一部分> 甚至可以是文件名的中间而不是开头.是否有等效的切换标签页?

When switching buffers I can use :b <part of filename><tab> and it will complete the names of files in existing buffers. <part of filename> can even be the middle of a filename instead of the beginning. Is there an equivalent for switching tabs?

推荐答案

停止,停止,停止.

这不是 Vim 选项卡的设计用途.事实上,他们的名字是错误的.更好的名称是视口"或布局",因为这就是选项卡的含义—它是所有现有缓冲区的不同窗口布局.

This is not how Vim's tabs are designed to be used. In fact, they're misnamed. A better name would be "viewport" or "layout", because that's what a tab is—it's a different layout of windows of all of your existing buffers.

试图将 Vim 击败到 1 个 tab == 1 个缓冲区是徒劳的.Vim 不知道也不关心,它不会在所有命令上尊重它——特别是,任何使用 quickfix 缓冲区的东西(:make:grep>:helpgrep 是那些浮现在脑海中的人)会很乐意忽略选项卡,并且您无能为力.

Trying to beat Vim into 1 tab == 1 buffer is an exercise in futility. Vim doesn't know or care and it will not respect it on all commands—in particular, anything that uses the quickfix buffer (:make, :grep, and :helpgrep are the ones that spring to mind) will happily ignore tabs and there's nothing you can do to stop that.

相反:

  • :设置隐藏
    如果您还没有此设置,请执行此操作.它使 vim 像地球上所有其他多文件编辑器一样工作.您可以编辑在某个窗口中不可见的缓冲区.
  • 使用:bn:bp:b#:b namectrl-6 在缓冲区之间切换.我自己喜欢 ctrl-6(单独切换到以前使用的缓冲区,或者 #ctrl-6 切换到缓冲区编号 #).
  • 使用 :ls 来列出缓冲区,或者像 MiniBufExplBufExplorer.
  • :set hidden
    If you don't have this set already, then do so. It makes vim work like every other multiple-file editor on the planet. You can have edited buffers that aren't visible in a window somewhere.
  • Use :bn, :bp, :b #, :b name, and ctrl-6 to switch between buffers. I like ctrl-6 myself (alone it switches to the previously used buffer, or #ctrl-6 switches to buffer number #).
  • Use :ls to list buffers, or a plugin like MiniBufExpl or BufExplorer.

这篇关于像缓冲区一样使用 Vim 的选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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