Open new files in existing Gvim
Kim Schulz, thursday d. 4. august 2011
If you use the Linux/Gnome file manager Nautilus for file navigation, and often open files in gvim, then this trick is for you.
With a few simple tricks you can easily change files to be opened in an existing Gvim window if it already exists.
First step is to copy your existing Gvim shortcut so you have an alternative to the normal one.
This is done by the following:
cd ~/.local/share/applications
cp gvim.desktop gvim-existing.desktop
Next open the file and make sure the contents looks like this:
[Desktop Entry]
Encoding=UTF-8
Name=GVim Text Editor (Existing)
Comment=Edit text files in existing vim
Exec=gvim --remote-silent %F
Terminal=false
Type=Application
Icon=/usr/share/pixmaps/vim.svg
Categories=Application;Utility;TextEditor;
StartupNotify=true
MimeType=text/plain;
NoDisplay=true
Finally you open nautilus and find one of the file you would normally edit in Gvim.
Right-click the file and select "Open with" ->"Other application". In the list of files you simply select the one called "GVim Text Editor (Existing)" and make sure to put a checkmark in the "Remember this application for ...."
Now whenever you open a file of that type, it will look for a running gvim and open the file in that one. If no gvim is running, then it will just start in a new instance as normal.
Permanent url: http://www.schulz.dk/en/blog/blogarchive/119
Want your own image next to your comment? Join Gravatar.com - it's free!