History Report a problem
Article Edit this page Discussion

Open files with existing Gvim window in Windows

From Vim Tips Wiki

(Redirected from VimTip1003)
Jump to: navigation, search

[edit] Duplicate tip

This tip is very similar to the following:

These tips need to be merged – see the merge guidelines.

Tip 1003 Previous TipNext Tip

Created: September 25, 2005 Complexity: basic Author: Anon Minimum version: 5.7 Karma: 42/23 Imported from: Tip#1003


You can enter the following at Windows command prompt to associate php files with gvim (change the command to suit your system):

assoc .php=PHPFile
ftype PHPFile="C:\Program Files\Vim\Vim63\gvim.exe" --remote "%1"

Then whenever you double click a .php file in Explorer, it will be opened in existing gvim window (or it will open new gvim window if there is no already opened gvim window).

[edit] Notes

  • assoc is the command to associate an extension with a filetype in the registry.
  • ftype is the command to set the action (program) that will be executed for a specific filetype.

[edit] Comments

I prefer the context menu that the Gvim installer gives you in a Windows install.

  • Edit with Vim
  • Edit with Existing Vim - <file name>

will appear when you right-click on a file in Explorer.

In fact if you have more than one gvim window open, all of them will appear in the context menu and so you can choose which existing gvim session to open your file within.


This also works with Gnome and KDE. And on Mac it's the standard way to open files in Vim.

It's smart to open files "inside" one instance of VIM. All your actions are saved (like yanking, pasting or searching) - and you really don't have to keep the track on the windows (by using mouse or alt+tab). Using a plugin like minibufexpl you can keep track of the buffers open.Another gain is to use multiply desktops - for instance, I have Nautilus on one and VIM on another.

Check out: minibufexpl


Maybe it is better to use --remote-silent instead of --remote. So you will not get a warning dialog, when opening a file, and no gvim is already running.


Associating files with gvim --remote-silent works pretty well for me, except in the following scenario:

  1. There is a gvim instance already running.
  2. I select multiple files in Explorer and hit Enter.

Some of the files that were selected will not be opened, they simply get "lost". It seems to work every time if I just select a single file. I figure it must be some sort of timing issue in the gvim server.


I tried your scenario, and all selected files opened in the already running instance of gvim.


Rate this article:

Share this article:

Hubs Highlights International Sites Wikia messages
Entertainment
Gaming
Cartoons & Comics
Science Fiction
Hobbies
Sports
See all...
Grand Theft Auto
Pushing Daisies
Legend of Zelda Wiki
Terminator Wiki
Everquest II Wiki
Godzilla
German
Spanish
Chinese
Japanese
More...
Wikia is hiring for several open positions
Send this article to a friend
"Open files with existing Gvim window in Windows"
 
 
Hi!

I thought you'd like this page from Wikia!

http://vim.wikia.com

Come check it out!
Send confirmation


.