使用Vim的选项卡,例如缓冲区 [英] Using Vim's tabs like buffers

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

问题描述

我研究了在Vim中使用制表符的功能(带有:tabe :tabnew 等)。 ),以代替目前在隐藏缓冲区中在同一窗口中打开多个文件的当前做法。



我希望打开的每个不同文件始终位于它自己的标签。但是,有些事情会影响到这一点。我该如何解决这些问题:


  1. gf ^] 跳转到另一个文件中的某个位置,该文​​件在当前选项卡的新缓冲区中打开。有没有一种方法可以让所有这些命令在新选项卡中打开文件,或者如果文件已经打开,则切换至带有该文件的现有选项卡?


  2. 切换缓冲区时,我可以使用
    :b<文件名的一部分>< tab>
    ,它将完成文件名在现有缓冲区中。 <文件名的一部分> 甚至可以是文件名的中间而不是开头。



解决方案

停止,停止,停止



这不是设计Vim标签的方式。实际上,它们的名字是错误的。一个更好的名字是 viewport或 layout,因为这是一个选项卡,它是现有缓冲区的 all 窗口的不同布局。



尝试将Vim分成1个制表符== 1个缓冲区是徒劳的。 Vim并不知道也不在乎,它不会在所有命令上都尊重它-特别是使用quickfix缓冲区的任何东西(:make : grep :helpgrep 会让人高兴地忽略那些选项卡,您无能为力。 >

相反:




  • :设为隐藏

    如果您尚未设置此设置,请这样做。它使vim像地球上所有其他多文件编辑器一样工作。您可以编辑在窗口某处不可见的缓冲区。

  • 使用:bn : bp :b#:b名称 ctrl-6 可以在缓冲区之间切换。我自己喜欢 ctrl-6 (单独将其切换到以前使用的缓冲区,或者将#ctrl-6 切换到缓冲区数字)。

  • 使用:ls 列出缓冲区,或像 MiniBufExpl BufExplorer


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. 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?

  2. 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?

解决方案

Stop, stop, stop.

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.

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.

Instead:

  • :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天全站免登陆