Vimer is an executable single-file script to open files in an existing instance of GVim or MacVim.
This project addresses the need for efficient file management when using GVim or MacVim across different operating systems. It simplifies opening files from the shell without cluttering the desktop with multiple windows or dealing with swap file warnings. Vimer enables editing in a single GVim or MacVim instance, handling files already in use seamlessly.
Opening files with gvim
or mvim
from the shell can lead to a cluttered desktop with multiple windows and swap file warnings when files are already open.
While internal editor commands can prevent this, shell-based file editing remains essential during directory navigation.
Alternative solutions, such as wrapper scripts (myvim.cmd
on Windows or alias myvim='gvim --remote-silent'
on Linux and Mac), partially address these issues but introduce new problems like errors when run without arguments or incorrect handling of piped commands.
However, this approach has shortcomings.
For instance, executing myvim
without arguments triggers an error, and piping output into GVim or MacVim with ls | myvim -
mistakenly opens an empty buffer named -
.
Vimer introduces a refined wrapper script that adeptly manages these exceptions.
Download vimer.cmd
for Windows / vimer
for Linux and Mac.
Place it in a directory in %PATH%/$PATH
.
(On Linux and Mac, grant execution rights with chmod u+x vimer
.)
Then, for example:
- Launch a new instance of GVim or MacVim with
vimer
. - Open files in the same instance with
vimer foo.txt bar.txt baz.txt
. - Use
-t
to open files in separate tabs withvimer -t foo.txt bar.txt baz.txt
. - Pipe command output into GVim or MacVim with
ls -l | vimer -
or in a new tab withls -l | vimer -t -
. - Start GVim or MacVim with a specific server name using
vimer -s FOO
. - Edit with a named server using
vimer -s FOO foo.txt bar.txt baz.txt
.
For detailed usage, run vimer --help
.
Users accustomed to vi
, vim
, gvim
, or mvim
may rename the script for convenience, such as changing vimer.cmd
to vi.cmd
on Windows or vi
on Linux or Mac.
If you use a file manager such as Total Commander (on Microsoft Windows or Linux/Mac OS), Double Commander or Krusader, then this is a great choice as a single instance editor (for a single instance file manager) by choosing it as preferred editor.
-
In Total Commander this is achieved by
- copying the
vimer
folder into%COMMANDER_PATH%\addons\vimer
- choosing
COMMANDER_PATH%\addons\vimer\vimer.cmd
in the Options Dialogue, or adding in the section[Configuration]
in the file%COMMANDER_PATH%\wincmd.ini
the lineEditor=%COMMANDER_PATH%\addons\vimer\vimer.cmd
.
- copying the
-
In Krusader in Options/Configure Krusader/Tools/Editor and setting the path
vimer --tab
-
In Double Commander in Configuration/Options/General/Editor, enable
external program
and choose as pathvimer --tab
(in case thevimer
script resides in a directory in$PATH
, otherwise its full path).
-
To use
vimer
as a default editor on Microsoft Windows, run NotepadReplacer once and for all. Use Text Editor Anywhere to paste the currently edited text (say in a entry box of the Browser) into it. -
On Linux, add an entry
~/.config/applications/mimeapps.list
[Default Applications] text/plain=vimer.desktop
where
~/.config/applications/vimer.desktop
reads[Desktop Entry] Type=Application Name=Vimer Exec=$HOME/bin/vimer %u
with
$HOME/bin
being replaced by the path of thevimer
script.
These scripts differ from Susam's original vimer scripts in
- launching an instance of Vim if none found on Microsoft Windows and Linux/ Mac OS,
- finding Vim by falling back an executable in
$PATH
or the one set by$EDITOR
on Microsoft Windows and Linux/ Mac OS, - no longer offering the creation of context menu entries on an administered Microsoft Windows machine