- ÂÛ̳»ÕÕÂ:
- 0
|
±¾Ìû×îºóÓÉ wyc198801wyc ÓÚ 2017-02-02 12:01 ±à¼
ÔÚvimÍøÕ¾ÉÏ¿´µ½Á˸öÓÐÒâ˼µÄÓ÷¨¸ú´ó¼Ò·ÖÏíһϣ¬¹²Í¬Ñ§Ï°¡£
Sessions Ó÷¨
Suppose you are editing along, and it is the end of the day. You want to quitwork and pick up where you left off the next day. You can do this by savingyour editing session and restoring it the next day. A Vim session contains all the information about what you are editing.This includes things such as the file list, window layout, global variables,options and other information. (Exactly what is remembered is controlled bythe 'sessionoptions' option, described below.) The following command creates a session file:
:mksession vimbook.vim
Later if you want to restore this session, you can use this command:
:source vimbook.vim
If you want to start Vim and restore a specific session, you can use thefollowing command:
vim -S vimbook.vim
This tells Vim to read a specific file on startup. The 'S' stands forsession (actually, you can source any Vim script with -S, thus it might aswell stand for "source").The windows that were open are restored, with the same position and size asbefore. Mappings and option values are like before. What exactly is restored depends on the 'sessionoptions' option. The default value is "blank,buffers,curdir,folds,help,options,winsize".
blank keep empty windows
buffers all buffers, not only the ones in a window
curdir the current directory
folds folds, also manually created ones
help the help window
options all options and mappings
winsize window sizesChange this to your liking.
To also restore the size of the Vim window, forexample, use:
:set sessionoptions+=resize
SESSION HERE, SESSION THEREThe obvious way to use sessions is when working on different projects.Suppose you store you session files in the directory "~/.vim". You arecurrently working on the "secret" project and have to switch to the "boring"project:
:wall
:mksession! ~/.vim/secret.vim
:source ~/.vim/boring.vim
This first uses ":wall" to write all modified files. Then the current sessionis saved, using ":mksession!". This overwrites the previous session. Thenext time you load the secret session you can continue where you were at thispoint. And finally you load the new "boring" session.If you open help windows, split and close various window, and generally messup the window layout, you can go back to the last saved session:
:source ~/.vim/boring.vim
|
|