2011-05-25 18 views

回答

3

是的,有針對的命令:

:[N]sb[uffer] [N]     :sb :sbuffer 
     Split window and edit buffer [N] from the buffer list. If [N] 
     is not given, the current buffer is edited. Respects the 
     "useopen" setting of 'switchbuf' when splitting. This will 
     also edit a buffer that is not in the buffer list, without 
     setting the 'buflisted' flag. 

您可能會發現這些的也有用:

:[N]sbn[ext] [N]         :sbn :sbnext 
     Split window and go to [N]th next buffer in buffer list. 
     Wraps around the end of the buffer list. Uses 'switchbuf' 

:[N]sbN[ext] [N]   :sbN :sbNext :sbp :sbprevious 
:[N]sbp[revious] [N] 
     Split window and go to [N]th previous buffer in buffer list. 
     Wraps around the start of the buffer list. 
     Uses 'switchbuf'. 

問題與兩個命令是,他們將水平拆分。你可以在它們前面加上:vert[ical],但是這打破了你的一個命令模式:-)

無論如何,:vert sb foo.py並沒有太多的輸入,如果你真的經常使用它,你可能要考慮爲它創建一個映射。也許類似於:

cnoremap ,sb vert sb 
1

只要告訴:vnew該文件的路徑:

:vnew foo.py 

編輯:

正如sidyll表示,目前在垂直分割窗口編輯緩衝區命令沒有內置,然後我創建新的Ex命令它你想要做什麼:

command! -nargs=1 -complete=buffer -bang Vbuffer vnew | buf<bang> <args> 

!command將取代舊:Vbuffer如果它存在(您可以刪除它,因爲我已經添加它進行測試),-nargs=1意味着新命令接受1參數,該參數被傳遞給:buf命令,<args>-complete=buffer將在您輸入標籤時建議緩衝區名稱參數名稱和-bang表示新命令接受!選項,該選項也通過<bang>傳遞給:buf命令。

只需將該行添加到您的~/.vimrc並將其重新編號爲:source即可。 ;-)

+0

As @ jm666說。我經常使用文件系統中的所有文件,所以我更喜歡使用:buf,因爲我只需要提供部分名稱。 – 2011-05-25 21:22:07

+0

改進了答案.. – freitass 2011-05-25 23:14:50

+0

Upvoting,真好。創建一個新的命令是一種在我看來並不存在的解決方案,在這種情況下,它比一張簡單的地圖要好得多。 – sidyll 2011-05-26 01:55:44

相關問題