views:

614

answers:

3

Is there a way to configure nautilus to open a file into an existing gvim process in a new buffer instead of loading a new instance of gvim? I know I can drag and drop the file into gvim, but it would be convenient if I could just double-click a file to open it.

A: 

Perhaps you can write a shell script to automate this if Gvim provides the functionality. I personally do not know enough to provide the details. Just a direction to try?

Brandon Pelfrey
+1  A: 

You're really just wanting to launch gVim with the --remote-tab-silent option. From the manual:-

          *--remote-tab-silent*
   --remote-tab-silent
   Like --remote-silent but open each file in a new tabpage.

Also just check out --remote-silent if you're not wanting a new tab and want to create a new buffer.

Gavin Gilmour
Any idea where gnome configures which program is associated with text files? System -> Preferences -> Preferred Applications seems to be the right area, but it doesn't allow you to pick a text editor there . . .
CMB
I'm on a mac so I'm not 100%, but you could try this :- http://www.howtogeek.com/howto/ubuntu/add-open-with-gedit-to-the-right-click-menu-in-ubuntu/ and use this script instead:- http://pastebin.com/m7abf308e It might do the trick.
Gavin Gilmour
+1  A: 

In a Terminal

cd ~/.local/share/applications
vi gvim-tab.desktop

Copy Paste this code :

[Desktop Entry]
Encoding=UTF-8
Name=GVim Text Editor (Tabs)
Comment=Edit text files in a new tab
Exec=gvim --remote-tab %F
Terminal=false
Type=Application
Icon=/usr/share/pixmaps/vim.svg
Categories=Application;Utility;TextEditor;
StartupNotify=true
MimeType=text/plain;
NoDisplay=true

In Nautilus

Right-Click in a text file
Open With
Open with a another application
Select "GVim Text Editor (Tabs)"

It's done

Touv
Awesome -- exactly what I was trying to figure out! Thank you! :D
CMB