tags:

views:

274

answers:

1

My usage-scenario may seem a bit unusual, but here it is: When using vim (it's one of about 4 different editors I use regularly), I use it in two different situations. The first is via the GUI, in which I'll have multiple buffers and have some settings different than when I use it from the command-line (by testing "if has('gui_running')"). The other is when I need to do something short-and-quick, from the command-line, such as make a small change to a dot-file or other type of config.

What I would like to do, is have sessions enabled for the GUI, but have any command-line invocations ignore them. That is, I don't want to bring up the full existing session on a CL invocation, nor do I want it (and whatever buffer/file it involved) to alter the session that the GUI is using. As I'm fairly new to the post-vi-functionality of vim, I'm not really sure how to pull this off.

+3  A: 

do your session magic in your .gvimrc and everything else in your .vimrc. The GUI will source both, but the CL version will only source the .vimrc.

The session magic is to set up autocommands to write your session to a file on exit, and reload it by sourcing the file upon entrance.

au VimLeave * mksession ~/.gvimsession
au VimEnter * source ~/.gvimsession
rampion
This does the trick, though I don't have to create a .gvimrc to use it-- it works fine within the GUI-only block of my .vimrc.
rjray