您可以將這些配置放入自定義腳本文件中,然後可以選擇使用該腳本文件打開您的工作區配置。
腳本文件:
:bl
:bf
:tabe
:n
:split
:vsplit
:wincmd l
:n
:wincmd j
:n
:n
:vsplit
:wincmd l
:n
:wincmd h
:wincmd k
:tabn
而且你可以把它作爲這樣的:
vim -S script.vim file1.txt file2.txt file3.txt file4.txt file5.txt
這將打開VIM在FILE1.TXT,以開放的標籤旁邊,根據您的配置,並在切換到左上角文件(file2.txt)時將光標放在上面。每一行的
加解釋:
注意,當我們分手時,光標會停留在原來的窗口上,並且每個窗口會顯示不同的文件,可以獨立使用:n
和:N
導航。當創建一個新窗口時,它將顯示與我們在創建窗口時所處窗口相同的文件。
正如我的評論所指出的那樣,前兩行是告訴VIM我們已經讀取了每個文件,因此VIM在會話結束時不會抱怨「需要編輯4個文件」。
:bl Go to last file
:bf Go to first file
:tabe Create new tab
:n Open next file (file2.txt)
:split Split horizontally (will create new window below with the content of file2.txt)
:vsplit Split vertically (will create new window on the top right with the content of file2.txt)
:wincmd l Go to the window to the right (which currently displays file2.txt)
:n Open next file (file3.txt)
:wincmd j Go to window at the bottom
:n Open next file (file3.txt, because bottom window was displaying file2.txt)
:n Open next file (file4.txt)
:vsplit Split vertically (will create new window on the right with content file4.txt)
:wincmd l Go to window to the right (which is bottom right)
:n Open next file (file5.txt, because bottom-right window was displaying file4.txt)
:wincmd h Go to window to the left
:wincmd k Go to window above (this sets the cursor on file2.txt on top left)
:tabn Go to next tab (the first one, displaying file1.txt)
你試過了什麼?它是如何失敗的? – romainl
你讀過這個嗎? [鏈接](http://stackoverflow.com/questions/53664/how-to-effectively-work-with-multiple-files-in-vim) – Antarus