我已经看到了在Vim中使用选项卡(使用:table,:tabnew等)的能力,以取代我目前在隐藏缓冲区的同一个窗口中打开多个文件的做法。
我想每个不同的文件,我已经打开,总是在自己的选项卡。然而,有一些事情阻碍了这一点。我如何解决这些问题:
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?
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?
You can map commands that normally manipulate buffers to manipulate tabs, as I've done with gf in my .vimrc:
map gf :tabe <cfile><CR>
I'm sure you can do the same with [^
I don't think vim supports this for tabs (yet). I use gt and gT to move to the next and previous tabs, respectively. You can also use Ngt, where N is the tab number. One peeve I have is that, by default, the tab number is not displayed in the tab line. To fix this, I put a couple functions at the end of my .vimrc file (I didn't paste here because it's long and didn't format correctly).
Vim:帮助窗口很好地解释了“选项卡与缓冲区”的混淆。
缓冲区是文件在内存中的文本。
窗口是一个视口
在缓冲器上。
标签页是窗口的集合。
打开多个文件是在vim中使用缓冲区实现的。在其他编辑器(例如notepad++)中,这是通过选项卡完成的,所以vim中的名称选项卡可能会误导。
Windows的目的是分隔工作空间并在一个屏幕上显示多个文件(缓冲区)。在其他编辑器中,这可以通过打开多个GUI窗口并在桌面上重新排列它们来实现。
最后,在这个类比中,vim的标签页将对应多个桌面,这是不同的窗口重排。
正如vim的帮助:标签页解释了一个标签页可以被使用,当一个人想要临时编辑一个文件,但不想改变任何在当前布局的窗口和缓冲区。在这种情况下,可以使用另一个选项卡页来编辑特定的文件。
当然,您必须记住,在许多选项卡页或窗口中显示相同的文件将导致显示相同的工作副本(缓冲区)。
You can map commands that normally manipulate buffers to manipulate tabs, as I've done with gf in my .vimrc:
map gf :tabe <cfile><CR>
I'm sure you can do the same with [^
I don't think vim supports this for tabs (yet). I use gt and gT to move to the next and previous tabs, respectively. You can also use Ngt, where N is the tab number. One peeve I have is that, by default, the tab number is not displayed in the tab line. To fix this, I put a couple functions at the end of my .vimrc file (I didn't paste here because it's long and didn't format correctly).