On 06/06/2012 03:57 AM, Christian Brabandt wrote:
> On Wed, June 6, 2012 01:02, Eric Weir wrote:
>>
>> On May 24, 2012, at 7:26 AM, Michael Henry wrote:
>>
>>> :mksession ~/SomeSessionName.vim
>>
>> Weird. When I do :mksession ~\startup.vim a second time, i.e., after
>> having quit vim and restarting, I get a message saying the file exists and
>> to add "!" to overwrite. When I do that, however, the file gets saved as
>> startup.vim! Then on the next source it loads the previous session, not
>> the last one.
>
> You need to add the ! to the mksession command, not to the file name ;)

Yes, I typically use the "!" as Christian suggests.  Since I
generally save my state to a single session file, I have it in
my Vim command-line history.  So I really just press ":mk" and
then press the up-arrow key to recall the most recent
":mksession" command, which in my case is::

  :mksession! ~/vim/Session.vim

Similarly, my most common use of the :source command is to
restore the above session, so I use command-line history to
bring it back.  I press ":so" and the up-arrow, and the first
recalled command is almost always::

  :source ~/vim/Session.vim

I keep session files by convention in ~/vim.  If you intend to
use the same session file routinely, I think you'd find that
it's pretty quick to use the history as I do.  But you could
also define your own custom commands to do it, perhaps by adding
something like the following to your ~/.vimrc::

  command! SS mksession! ~/vim/Session.vim

Then you could do :SS to save a session.  You could add a
similar command to restore (or load) a session::

  command! LS source ~/vim/Session.vim

Even if you define your own commands, I recommend trying the
command-line history feature.  It's very useful to be able to
find the most recent command of a given type.  For example,
after a global replace operation like this::

  :%s/old text/new text/g

I frequently want to do a similar operation.  Pressing ":%" and
the up-arrow lets me find and adjust a previous command that's
similar to what I want without retyping it all again.  (If you
want to repeat the previous replacement exactly, Vim has the
two-character "g&" sequence that's faster.  Similar comments
apply for other specific commands, but the history mechanism is
pretty useful in general.)

Also, as mentioned by Ben Fritz, you can adjust what is saved in
a session file by ":mksession".  In my ~/.vimrc, I have the
following:

  set sessionoptions=blank,buffers,curdir,folds,help,resize,slash
            \,tabpages,unix,winpos,winsize

This keeps my session files from having Vim options that would
typically be in the ~/.vimrc, while preserving things like the
window layout, the cursor positions in the buffers, etc.

Michael Henry

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to