代码改变世界

Vim的tab和buffer

2012-10-30 20:16  夜幕降临  阅读(1366)  评论(0编辑  收藏  举报

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的buffer和tab是一个让人容易误解的概念。Tab更合理的名字应该叫做“视口(viewport)”或者“布局(layout)”,Tab相当于是对已经存在的buffer的不同表现形式。

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.

我们要改变 1 tab == 1 buffer的概念,在vim中普遍使用quickfix buffer的概念(参看link

我们要以如下的方式使用vim的buffer

    • :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.