Yes, but first make sure
vim --version | grep clientserver returns
If it returns
- instead of
+, an easy way to enable that capability is to install gVim.
In Debian and Ubuntu, for example,
sudo apt-get install vim-gtk3 installs it.
An alternative is to compile Vim with that option.
Now that you have
+clientserver, create the file
vimserver with contents:
case "$(vim --serverlist)" in
*XTVIM*) vim --servername XTVIM --remote-tab "$@" ;;
*) x-terminal-emulator -e vim -p --servername XTVIM "$@" & ;;
Don't forget to put
vimserver in a directory in your
and to make it executable with
chmod +x vimserver.
Also, for the fourth line, find in your terminal manpage what is
the appropriate flag to execute the
command in a new terminal window. For XTerm, it is indeed the
-e flag, but for
Gnome-terminal1, Xfce4-terminal and Terminator, it is the
Test it on some files (multiple files can be passed in the arguments):
vimserver file1 file2
vimserver file3 file4 file5
Each file should be opened in a new tab of a same Vim instance.
If you want new files to be in a new buffer,
not a new tab, just change
--remote and remove the
Edit the extension file
%s macro means that not only a single selected file can be opened, but also multiple tagged files!
filextype * vimserver %f
~/.config/vifm/vifmrc and also
accordingly modify the text filetypes you have possibly set (e.g.
filextype *.c vimserver %f). Opening multiple tagged files is suported, too.
Edit > Preferences > Programs > Text editor.
Xfe can also open multiple tagged files at once.
Pcmanfm, Thunar, Nemo, Rox, and probably other GUI file-managers
Although the menu entries labels may vary a bit, the procedure is the same.
Right click a text file,
Open with... > Custom command line / Use a custom command.
In the command text field, enter
vimserver and mark the checkbox or press the button that sets it as default.
The case statement checks if the Vim server XTVIM exists. If yes (3rd line),
XTVIM loads the file. If not (4th line),
a new terminal is launched and new Vim server (named XTVIM) with it. The file is loaded in that
new Vim instance.
A specific terminal can be specified, for example,
xterm instead of
You may find out that your DE/WM does not focus the terminal with Vim when a file is opened in
an already existing server. For XTerm, adding a
xdotool line solves that:
case "$(vim --serverlist)" in
xdotool search --classname vimserver windowactivate
vim --servername XTVIM --remote-tab "$@" ;;
*) xterm -name vimserver -e vim -p --servername XTVIM "$@" & ;;
Because of the
xdotool can locate the Vim window and request focus to it.
I have read the manpages of some modern terminals (Gnome, Xfce...) but could not find a
similar option for them.
If you are OK with gVim1, do not bother with
vimserver. Just use
gvim --remote-tab-silent. Using MC as example, this would go in
Open=gvim --remote-tab-silent %f &
1 User @goldilocks comments about the gVim usage in his answer of
What are practical uses of the client-server mode?.