You can use vim's :mksession and write each "workspace" to a different file, then reopen a session using vim -S session_file, however, if you're open to using a plugin then I find the vim-startify plugin is exactly what I need for this sort of scenario.
It does a great job of managing sessions, in vim and mccvim, and it gives you a list of recent files as ...
You can use tpope's vim-obsession plugin to easily manage sessions. It is like a wrapper to Vim's in-built mksession, but provides a set of other niceties as well.
You can save the current session (or buffer layout) by giving the command :Obsession. If you don't supply an argument, it writes a session file called Session.vim by default.
To reload a ...
You need vim compiled with +clientserver, and then you can use the command:
vim --servername SERVER to start a vim instance, and
vim --servername SERVER --remote FILE to open the file in the named vim instance.
MacVim runs a server by default - you can use
mvim --remote-tab-silent to open a file in a new tab in your existing MacVim instance,...
As a side note, I'd like to point out that I built yet another plugin dhruvasagar/vim-prosession as an extension to tpope/vim-obsession that enhances it even further to create & manage vim sessions by default in a centralised repository as per configuration on a per directory basis and loads them automatically when you launch vim without any arguments on ...
In vim, there is a feature which allows you to save your current session to a vimscript file. This can be done using the :mksession command. Here is a synopsis of the command given in the vim documentation:
Write a Vim script that restores the current editing session.
When [!] is included an existing file is overwritten.
When [file] ...
Vim has a built-in session mechanism, from :h session:
A Session keeps the Views for all windows, plus the global settings. You can
save a Session and when you restore it later the window layout looks the same.
You can use a Session to quickly switch between different projects,
automatically loading the files you were last working on in that ...
You can save a session of vim with all its settings including your open tabs with
and load it with
if you don't want to store options like your colorscheme and font size you can disable storing them with this entry in your vimrc
While @craigp's answer is correct, I found it most convenient to simply add --remote-silent without worrying about server names,(this assumes you don't want to address named vim instances).
This will start the server, or use one if its not already started.
It can be called like this:
gvim --remote-silent '+cal cursor(line,col)' some_file
You could use the following function. It is extremely hacky and I haven't tested
it plenty but it seems to work.
The idea is to create a command :Mksession which will work like the original
:mksession but will also save the unnamed buffers.
(Note that I had some inspiration from this
To do so it will call a function which does the following:
See :h :mksession, the 10th point:
If a file exists with the same name as the Session file, but ending in
"x.vim" (for eXtra), executes that as well. You can use *x.vim files to
specify additional settings and actions associated with a given Session,
such as creating menu items in the GUI version.
... I have a feeling this is the issue.
From doc/automatic-tex-plugin.txt in the Automatic LaTeX Plugin source:
Setting one of the variables |b:atp_ProjectScript| or
|g:atp_ProjectScript| to 0 the feature will be turned off. Local
variable, i.e. b: has ...
Your last comment says that your default colorscheme is sourced twice : once before your custom highlight groups, and once after.
The second time it's loaded, your custom highlight groups must be overwritten.
I think the reason why your default theme is loaded a second time when you source your Session.vim, is because the latter includes this line (83) :
The :map command defines a new mapping, while the :unmap removes them.
If you define a new mapping, it will remain there until you explicitly removes it. Your session file is probably saving it, so when you reload your session it is back. You can inspect the contents of your session file to confirm it.
Thus you probably can continue using your session if ...
The vim-lastplace plugin does exactly what you want (I am the author). It improves on the above code snippet by handling commit messages intelligently. If you have debian-testing you can apt-get install vim-lastplace to quickly try it out.
As I mentioned in my comments a session is associated with a single invocation of Vim so you can't do exactly what you're hoping to do. But I also mentioned something might be possible using shell scripts and Vim's "clientserver" functionality. I decided to chase that down...primarily for my own edification but since it works I figured I'd share it. (Your ...
Assuming you have a viminfo file (located at ~/.viminfo on Linux/Unix systems and $HOME\_viminfo on Windows), all of your buffers should be persistent across Vim sessions.
Note that if you're on a Linux/Unix system, this file must be owned by you (ls -l ~/.viminfo to verify that it is and chown $USER ~/.viminfo if it's not). Otherwise, it will have no ...
The behavior of :mksession is driven by the flags you have set in 'sessionoptions' (alias 'ssop'). The two flags that are likeliest to be factors here are curdir and sesdir. The former is simple, the current directory will be saved in the session data. The entry for sesdir in Help says:
sesdir the directory in which the session file is located
E189 "..." exists (add ! to overwrite) is reported by :h :mksession if session file exists , add ! after mks should fix that:
exe 'command Sdfs mks!' sessionlocation
If you want to pass ! from Sdfs to mks, use this:
exe 'command -bang Sdfs mks<bang>' sessionlocation
This is indeed a bug in Vim. I filed a GitHub issue, and someone on the vim-dev mailing list addressed it.
Here's a patch that fixes it in Vim 8.0.52:
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 439467c..ca4133a 100644
@@ -11091,6 +11091,8 @@ makeopens(
if (tabnr > 1)
There's nothing built-in; I guess the reasoning is that spelling (at least for a certain language) is inherently global. Any differences should be reflected in the language / dialect chosen.
You can implement such buffer-local spelling exception yourself: Get a temp file via tempname(), prepend it to 'spellfile', and then zg / 1zg will place the exception ...
I know this is old but I came across it and thought a different option might be useful for other people searching for this question.
I would yank to the system register and then open the new file and paste from the system register.
First find out what symbol represents your system clipboard. In Linux you have two options + or *. I use + but more info can ...
The issue is that you need to escape your space:
alias viml='vim -c :SLoad\ zzz'
Let's consider a simpler case:
I have a file named a.vim in the current directory and my alias is:
alias vv="vim -c :sp a.vim"
When I run vv I get two buffers with a.vim on each.
Why is that?
Vim open a.vim and then execute the command :sp, which split the buffer in ...
What I use (adapted from :help restore-cursor):
" Go to the last cursor location when a file is opened, unless this is a
" git commit (in which case it's annoying)
au BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") && &filetype != "gitcommit" |
\ execute("normal `\"") |
BufReadPost gets run ...
There's a single :h v:oldfiles list saved to / restored from :h viminfo. And it has nothing to do with :h session-file.
On the other hand, "session" does not store "oldfiles"-sort of stuff. What it contains is a buffer list (possibly including unloaded buffers, see :h 'sessionoptions'), but this still differs from "MRU" (Most ...
Assuming the functions are something you don't want all the time, so you don't want them in your .vimrc file, you can define them in a separate file and use :source filename to load in the definitions. This avoids the security issues of set exrc and loading untrusted files.
If the pathname to your functions file is irritatingly long, you could even define ...
write temporary notes/code in predefined system-wide or project-wide files (possibly with the help of some custom functions/mappings)
use a Vim note-taking plugin
In both cases notes are saved in files, so when reopening your session their content will not be lost. When starting a new unit of work, just erase the previous content of the ...