Vim Tips Wiki
(Fix "Sent To" typo, remove incorrect reference to MS-DOS, tweak "Send To" instructions)
(→‎Using Windows Send To Menu: cleaning up for clarity and adding wiki link)
Line 24: Line 24:
 
Now, double-clicking on .c or .h files will open them in tabs in gvim.
 
Now, double-clicking on .c or .h files will open them in tabs in gvim.
   
===Using Windows ''Send To'' Menu===
+
===Using Windows' ''Send To'' Menu===
Obviously, you can't enter file associations for every file you'll ever open in Vim. To provide the capability for these files, you'll need to add an entry to your "Send To" context menu. To do this, follow these steps:
+
Obviously, you can't enter file associations for every file you'll ever open in Vim. To provide an "open in tabs" capability for files without an association, you can [[Add_Vim_to_Windows_Send_To_menu|add an entry to your "Send To" context menu]], as follows:
   
 
#Click Start, Run then enter <tt>SendTo</tt> (you may need to enter <tt>%USERPROFILE%\SendTo</tt>).
 
#Click Start, Run then enter <tt>SendTo</tt> (you may need to enter <tt>%USERPROFILE%\SendTo</tt>).
#Click 'OK' to open a shortcut folder. Add a shortcut to gVim.
+
#Click 'OK' to open the SentTo directory, which contains all the shortcuts in your SendTo context menu. Add a shortcut to gvim or Vim as desired.
#Edit the 'Target' box in the Properties of the gVim shortcut to read:<pre>"C:\Program Files\Vim\vim71\gvim.exe" --remote-tab-silent</pre>
+
#Edit the 'Target' box in the Properties of the gVim shortcut to read: <pre>"C:\Program Files\Vim\vim71\gvim.exe" --remote-tab-silent</pre> (with your own system's path to Vim, of course).
   
In Windows Explorer, right-click one or more files, and select Send To, gVim in the context menu. You can repeat this to open other files in new tabs in the same Vim instance.
+
In Windows Explorer, right-click one or more files, and select Send To, gvim in the context menu. You can repeat this to open other files in new tabs in the same Vim instance.
   
 
==See Also==
 
==See Also==

Revision as of 16:47, 31 December 2007

Duplicate tip

This tip is very similar to the following:

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

Previous TipNext Tip

Tip: #1440 - Launch files in new tabs under Windows

Created: December 14, 2006 Complexity: basic Author: Xu Song Version: n/a Karma: 294/101 Imported from: Tip#1440

Many text editors automatically launch new files in tabs when you open them, rather than a separate window for every new file. Here's how to make Vim behave that way under Microsoft Windows.

Using File Associations

To automatically open a file in a Vim tab with a double-click or other "Open" action, you need to set up file associations. Open a command prompt window (Start, Run cmd.exe). For this example, I will use C source-code files. Modify these commands for whatever file type you want. Also, you may need to change the path to suit your system. At command prompt, type:

ftype code="C:\Program Files\Vim\vim71\gvim.exe" --remote-tab-silent "%1"
assoc .c=code
assoc .h=code

Now, double-clicking on .c or .h files will open them in tabs in gvim.

Using Windows' Send To Menu

Obviously, you can't enter file associations for every file you'll ever open in Vim. To provide an "open in tabs" capability for files without an association, you can add an entry to your "Send To" context menu, as follows:

  1. Click Start, Run then enter SendTo (you may need to enter %USERPROFILE%\SendTo).
  2. Click 'OK' to open the SentTo directory, which contains all the shortcuts in your SendTo context menu. Add a shortcut to gvim or Vim as desired.
  3. Edit the 'Target' box in the Properties of the gVim shortcut to read:
    "C:\Program Files\Vim\vim71\gvim.exe" --remote-tab-silent
    (with your own system's path to Vim, of course).

In Windows Explorer, right-click one or more files, and select Send To, gvim in the context menu. You can repeat this to open other files in new tabs in the same Vim instance.

See Also

Comments