Vim
保存目前 vim 會話狀態並稍後恢復(例如緩衝區、拆分等)
作為一個老 VIM 使用者,首先被它吸引,尤其是因為它直接的正則表達式替換允許非常快地工作,我並不真的期望 VIM 有這樣的功能。但是,到底是什麼,也許我忽略了一些東西或一些新奇事物。
vim
當以適應螢幕大小的 n-column-split 模式(請參閱下面的 bash 命令/別名)重新打開大量文件(即項目的所有 cpp/h 源文件)時,您是否知道一種方法以前的打開/選定/活動緩衝區是否會返回而不是重置為可見緩衝區中的第一個文件?有點像 IDE 會這樣做,通過保存打開的文件狀態。# check the window size after each command and, if necessary, # update the values of LINES and COLUMNS. shopt -s checkwinsize alias vimcpp='find . \( -name '\''*.cpp'\'' -o -name '\''*.cc'\'' -o -name '\''*.cxx'\'' -o -name '\''*.c'\'' -o -name '\''*.hpp'\'' -o -name '\''*.hh'\'' -o -name '\''*.hxx'\'' -o -name '\''*.h'\'' \) -exec vim -O$(( ( ( $COLUMNS - 1 ) / 80 > 0 ) ? ( ( $COLUMNS - 1 ) / 80 ) : 1 )) \{} \+'
您可以為此使用 vim 會話。趕緊跑:
:mksession mysession.vim
並且將在目前目錄中創建一個文件(稱為’mysession.vim’)。下次打開 vim 時,可以執行以下操作:
:source mysession.vim
(或您命名的任何名稱),您會發現自己回到了創建會話文件時的狀態(所有拆分都將在那裡等)。
從幫助:
This is introduced in sections 21.4 and 21.5 of the user manual. :mks[ession][!] [file] Write a Vim script that restores the current editing session. When [!] is included an existing file is overwritten. When [file] is omitted "Session.vim" is used. The resulting file, when executed with a ":source" command: 1. Restores global mappings and options, if 'sessionoptions' contains "options". Script-local mappings will not be written. 2. Restores global variables that start with an uppercase letter and contain at least one lowercase letter, if 'sessionoptions' contains "globals". 3. Closes all windows in the current tab page, except the current one; closes all tab pages except the current one (this results in currently loaded buffers to be unloaded, some may become hidden if 'hidden' is set or otherwise specified); wipes out the current buffer, if it is empty and unnamed. 4. Restores the current directory if 'sessionoptions' contains "curdir", or sets the current directory to where the Session file is if 'sessionoptions' contains "sesdir". 5. Restores GUI Vim window position, if 'sessionoptions' contains "winpos". 6. Restores screen size, if 'sessionoptions' contains "resize". 7. Reloads the buffer list, with the last cursor positions. If 'sessionoptions' contains "buffers" then all buffers are restored, including hidden and unloaded buffers. Otherwise only buffers in windows are restored. 8. Restores all windows with the same layout. If 'sessionoptions' contains "help", help windows are restored. If 'sessionoptions' contains "blank", windows editing a buffer without a name will be restored. If 'sessionoptions' contains "winsize" and no (help/blank) windows were left out, the window sizes are restored (relative to the screen size). Otherwise, the windows are just given sensible sizes. 9. Restores the Views for all the windows, as with |:mkview|. But 'sessionoptions' is used instead of 'viewoptions'. 10. If a file exists with the same name as the Session file, but ending in "x.vim" (for eXtra), executes that as well. You can use *x.vim files to specify additional settings and actions associated with a given Session, such as creating menu items in the GUI version.