Using vim sessions with GUI only?

My use case may seem a little unusual, but here it is: when using vim (this is one of four different editors that I use regularly), I use it in two different situations. The first is through a graphical interface in which I will have several buffers, and I have some settings that are different from when I use it from the command line (by testing " if has('gui_running')"). Another thing is when I need to do something short and quick from the command line, for example, make a small change to the point file or another type of configuration.

What I would like to do is enable sessions for the GUI, but any command line calls ignore them. That is, I do not want to display the entire existing session on a CL call, and I do not want it (and whatever buffer / file it uses) to change the session used by the GUI. Since I'm pretty new to vim post-vi functionality, I'm not quite sure how to do this.

+1
source share
2 answers

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

The session mask is to configure the auto-commands to write the session to a file when exiting and reloading it by searching for the file at the entrance.

au VimLeave * mksession ~/.gvimsession
au VimEnter * source ~/.gvimsession
+5
source

! mksession, .

au VimLeave * mksession! ~/.gvimsession
au VimEnter * source ~/.gvimsession
+2

All Articles