Vim Tips Wiki
Register
(Redirect to VimTip1440)
(Redirect to Launch files in new tabs under Windows)
Line 1: Line 1:
#REDIRECT [[VimTip1440]]
+
#REDIRECT [[Launch files in new tabs under Windows]]
 
{{Deprecated|The problem solved by this tip appears to have been fixed. See [[VimTip1440]] for how to do this properly.}}
 
{{Deprecated|The problem solved by this tip appears to have been fixed. See [[VimTip1440]] for how to do this properly.}}
 
{{review}}
 
{{review}}

Revision as of 07:28, 28 August 2012

This tip is deprecated for the following reasons:

The problem solved by this tip appears to have been fixed. See VimTip1440 for how to do this properly.

Tip 1314 Printable Monobook Previous Next

created August 24, 2006 · complexity basic · author Derrick Sobodash · version n/a


I've seen all the other open in tabs threads and there were still problems. For example, if you have a running Vim and want to have your next Edit with Vim go into that window as a tab, adding -p to "HKLM\Software\Vim\gvim\path" will not do it. Similarly, adding --remote-tab-silent will get them into the window, but you will always have an error from an extra parameter gvimext.dll. This was mentioned in a reply to Tip #1225 where files "opened funny".

So what's the solution? Get rid of gvimext.dll. It is a real piece of software. Google said there is a hacked one that fixes these problems, but the author's page seems to be long gone.

To drop gvimext.dll, you need to delete the key "HKCR\*\shellex\ContextMenuHandlers\gvim\". Make a backup first in case you want to restore it later. Alternatively, I think during the Vim 7.0 installer you can select not to install the context menu shortcuts. You can probably also delete "HKLM\Software\Vim\" since I don't think anything uses it now.

Now we need to create a new context menu. Save the following as vim_context.reg:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT*ShellEdit with &Vim]

[HKEY_CLASSES_ROOT*ShellEdit with &Vimcommand]
@="\"C:\Program Files\Vim\vim70\gvim.exe\" -p --remote-tab-silent \"%1\" \"%*\""

This will give you a new Edit with &Vim command for all files (& is the underscore hotkey for V like the old link had). It will appear in the first section of your context menu at the very end (above the first division). Clicking this will send all new documents to the current Vim window and open them in a new tab instead of int he current buffer. Also, the -p option makes it so you can select groups of files and open them into new tabs in the current Vim instance.

Comments

If you are going to get rid of the .DLL then you need to come up with all the same functionality. Diff on files, open all selected in Vim, open in separate instances etc.

I see you can open all files in one instance, but the diff and the separate instances remain to be hacked into the registry.


If you want the old functionality of open a group in a new Vim instance or View a Diff, I recommend you just keep the old DLL in addition to adding my new command. I'm not sure there's actually a way to do those with the registry because Windows is trying to execute the command once for every file instead of executing the command on all the filenames.

I'm sure this would be possible using some kind of scripting file, but that kind of defeats the purpose.

So if you need the Diff option or the open selected files together in new Vim instance, keep the DLL. You could still add my command from the first post, but don't follow the delete instructions.


The escaping is wrong in that reg file. It should look like:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\Shell\Edit with &Vim]

[HKEY_CLASSES_ROOT\*\Shell\Edit with &Vim\command]
@="\"C:\\Program Files\\Vim\\vim70\\gvim.exe\" -p --remote-tab-silent \"%1\" \"%*\""

Neither reg file could implement open-in-tabs. That's frustrating we still don't a sample solution for vim users in windows.


What exactly was the problem? I just tried the following on a Windows XP system that had gvim 7.1 installed. It worked.

  • I changed it to "REGEDIT4" because that works and is simpler.
  • I inserted "Tab " in the text because this system already had "Edit with Vim" in the right-click context menu of Explorer.
  • I fixed the path to match where gvim.exe is installed.
  • With administrator privilege, I ran file opentab.reg containing the three lines below.
  • It added entry to registry.
  • Explorer immediately showed an extra item in context menu.
  • Using that item opens target file in a new tab in one instance of gvim.
REGEDIT4
[HKEY_CLASSES_ROOT\*\Shell\Tab Edit with &Vim\command]
@="\"C:\\Program Files\\vim\\vim71\\gvim.exe\" -p --remote-tab-silent \"%1\" \"%*\""

In the past, I have also successfully tested Launch files in new tabs under Windows. These "open in tabs" tips need cleaning up! --JohnBeckett 11:33, 20 August 2008 (UTC)

This one in particular! I'm fairly sure (though not 100%) that deleting a .dll file is not a necessary step in adding an open-in-tabs item to the Windows context menu. --Fritzophrenic 12:41, 20 August 2008 (UTC)

John, Thanks a lot! "Tab Edit with Vim" works fine. My system is Vim7.1 and windowsXP.

John, one more thank you, "Tab Edit with Vim" works and does not get rid of the other useful things that the DLL does. Just have to make sure the path is correct, mine is vim72! Vim7.2 on XP.