I recently discovered -p
and --remote-tab
. Since I edit loads of files at the same time, sometimes with over 50 gvim instances open (and I am not a fan of buffers), I could use a bit of decluttering. However, at the same time, I don't want to push them all in a single instance. In other words, I want to open files in gvim tabs, but keep the ability to have multiple instances and control in which one I open any new file(s) I decide to open. That way I could group files in gvim instances the way I see fit.
My intended approach was to make two simple aliases in .bashrc
:
alias gvim="gvim -p"
alias gvimt="gvim --remote-tab"
What I expected was that gvim paths/to/some/files*
would open a new instance with those files in tabs, and that works as expected. However, I also expected gvimt paths/to/some/files*
to do the same in my last active gvim instance, but that did not happen. Instead, it seems to pick some default instance (possibly the first one I opened; not sure).
How do I make gvimt
, either through that alias or through vimrc
settings (but, ideally, without vim plugins), open files in tabs of the last active instance ("window", in window manager terms) instead of whatever is the default?
Maps
For completeness, the following maps work nicely with the accepted solution below:
" Ctrl+Tab and Ctrl+Shift+Tab
map <C-Tab> gt
map <C-S-Tab> gT
map! <C-Tab> <C-O>gt
map! <C-S-Tab> <C-O>gT
These make Ctrl+Tab
and Ctrl+Shift+Tab
behave as they usually do in editors (next/previous tab, respectively).