Vim Tips Wiki
Register
No edit summary
 
m (Added to Windows Category + minor enhancements)
Line 9: Line 9:
 
|rating=42/23
 
|rating=42/23
 
|text=
 
|text=
For example,
+
For example, type in console / cmd.exe (winnt <=)
 
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 ==
 
* <tt>assoc</tt> is the command to associate an extension with a filetype in the registry
 
* <tt>ftype</tt> is the command to set the action (program) that will be executed for a specific filetype
   
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).
 
 
}}
 
}}
   
 
== Comments ==
 
== Comments ==
Where to put those 2 lines?
 
 
'''Anonymous'''
 
, September 25, 2005 22:35
 
----
 
in console / cmd.exe (winnt &lt;=)
 
 
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
 
 
cherry_avium--AT--yahoo.com
 
, September 26, 2005 0:26
 
----
 
 
I actually prefere the context menu that the Gvim installer gives you in a Windows install.
 
I actually prefere the context menu that the Gvim installer gives you in a Windows install.
  +
* Edit with Vim
 
Edit with Vim
+
* Edit with Existing Vim - &lt;file name&gt;
Edit with Existing Vim - &lt;file name&gt;
 
   
 
will appear when you right-click on a file in Explorer.
 
will appear when you right-click on a file in Explorer.
Line 52: Line 37:
 
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.
 
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 [/scripts/script.php?script_id=159 vimscript &#35;159]
+
Check out: {{script|id=159|text=minibufexpl}}
   
 
amix at amix.dk
 
amix at amix.dk
Line 59: Line 44:
 
Thank you for that helpful tip.
 
Thank you for that helpful tip.
 
But 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.
 
But 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.
 
 
   
   
Line 67: Line 50:
 
----
 
----
 
Associating files with GVIM --remote-silent works pretty well for me, except in the following scenario:
 
Associating files with GVIM --remote-silent works pretty well for me, except in the following scenario:
 
# there is a GVIM instance already running.
 
 
# I select multiple files in File Explorer and hit Enter.
1. there is a GVIM instance already running.
 
2. I select multiple files in File 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. It figure it must be some sort of timing issue in the GVIM server.
 
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. It figure it must be some sort of timing issue in the GVIM server.
Line 104: Line 86:
 
----
 
----
 
<!-- parsed by vimtips.py in 0.586361 seconds-->
 
<!-- parsed by vimtips.py in 0.586361 seconds-->
  +
  +
  +
[[Category:Windows]]

Revision as of 14:35, 27 August 2007

Previous TipNext Tip

Tip: #1003 - Windows file associations

Created: September 25, 2005 19:48 Complexity: basic Author: Associate files with Gvim in Windows Version: 5.7 Karma: 42/23 Imported from: Tip#1003

For example, type in console / cmd.exe (winnt <=)

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 actually prefere 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.

Craig Emery , September 26, 2005 1:10


This also works with Gnome / 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

amix at amix.dk , September 26, 2005 1:10


Thank you for that helpful tip. But 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.


info--AT--cvjb.de , September 30, 2005 3:58


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 File 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. It figure it must be some sort of timing issue in the GVIM server.

Has anyone else experienced this and found a workaround?


markcpa-at-pacbell-dot-net , September 30, 2005 11:17


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

info--AT--cvjb.de , October 5, 2005 1:30


didn't work for me using cmd

so I tried it from folder options->filetypes instead. I had to restore the changes I made in the shell before entering the advanced dialog. (the restore button changes to the advanced button after you do this)

then:

&Same Vim Window "C:\Program Files\Vim\Vim63\gvim.exe" --remote "%1" (forget the dde fields, they get filled in automatically)

and set as default

if you were doing a log of files it would probably take less time than using cmd since u can use ctrl-v!


Anonymous , October 15, 2005 4:02