Vim Tips Wiki
Register
(Change to TipImported template + severe manual clean)
(Move categories to tip template)
Line 10: Line 10:
 
|version=5.7
 
|version=5.7
 
|rating=42/23
 
|rating=42/23
  +
|category1=Windows
  +
|category2=
 
}}
 
}}
 
You can enter the following at Windows command prompt to associate php files with gvim (change the command to suit your system):
 
You can enter the following at Windows command prompt to associate php files with gvim (change the command to suit your system):
Line 54: Line 56:
   
 
----
 
----
[[Category:Windows]]
 

Revision as of 08:48, 25 April 2008

Duplicate tip

This tip is very similar to the following:

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

Tip 1003 Printable Monobook Previous Next

created September 25, 2005 · complexity basic · author Anon · version 5.7


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).

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.

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.