Thursday, June 21, 2012

Re: Can vim be made to start with selected files already open?

On Jun 7, 2012, at 9:28 PM, Michael Henry wrote:

> 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

Thanks for introducing me to the command line history. Didn't know it existed.

> 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

I've been relying on the 'mksession' solution so far, and most of the time it does exactly what I want done. But as explained in my response to Christian, I think I'd prefer a solution that doesn't save the entire state, just which files were loaded.

> 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.

I'll look into this. Looks like it would avoid the problem of the session file overwriting changes to the vim state that I don't want to overwrite.

------------------------------------------------------------------------------------------
Eric Weir
Decatur, GA USA
eeweir@bellsouth.net

"Uncertainty is an uncomfortable position,
but certainty is an absurd one."

- Voltaire

--
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

No comments: