Vim使用技巧之tab and buff


 vim中的buffer、tab、window說明

Vim :help window explains the confusion "tabs vs buffers" pretty well.

A buffer is the in-memory text of a file.
A window is a viewport on a buffer.
A tab page is a collection of windows.

Opening multiple files is achieved in vim with buffers. In other editors (e.g. notepad++) this is done with tabs, so the name tab in vim maybe misleading.

Windows are for the purpose of splitting the workspace and displaying multiple files (buffers) together on one screen. In other editors this could be achieved by opening multiple GUI windows and rearranging them on the desktop.

Finally in this analogy vim's tab pages would correspond to multiple desktops, that is different rearrangements of windows.

As vim help: tab-page explains a tab page can be used, when one wants to temporarily edit a file, but does not want to change anything in the current layout of windows and buffers. In such a case another tab page can be used just for the purpose of editing that particular file.

Of course you have to remember that displaying the same file in many tab pages or windows would result in displaying the same working copy (buffer).


用vim的tab代替隱藏的buff(暫時沒成功)

:tab sball - this opens a new tab for each open buffer.

:help switchbuf - this controls buffer switching behaviour, try :set switchbuf=usetab,newtab. This should mean switching to the existing tab if the buffer is open, or creating a new one if not.


切換和查看所有打開的buffers
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.
各個打開的tabs之間進行切換
使用gt, gT,num+gt進行各個tabs之間的切換。

NERDTree:
"opening NERDTree automaticlly when open vim                              
autocmd vimenter * NERDTree                                              
                                                                          
"opening NERDTree automaticlly only if open vim without specific file .      
autocmd StdinReadPre * let s:std_in=1                                     
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif

Tagbar:

Put something like the following into your ~/.vimrc:


vim-airline:
配置statusbar.



發佈了297 篇原創文章 · 獲贊 36 · 訪問量 31萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章