In Windows, open the file on the Vim Tab

Source: Internet
Author: User

When we use vim in windows, we often choose "Edit with Vim" from the context menu to open the file. However, files opened in this way will be opened in the new window, rather than in a new tab like Ultra Edit.

VIM 7.0 already supports tabs. How can I create a new tag instead of a new window when opening a file? The following VBScript implements this function by modifying the registry. Don't worry, it won't damage your registry.

Save the following content to a file named vim. vbs:

 

Option Explicit 'forces the display of declared variables.
On Error Resume Next 'do not handle errors

Dim WSHShell
Set WSHShell = WScript. CreateObject ("WScript. Shell ")

WSHShell. RegDelete "HKEY_CLASSES_ROOT" * "OpenWithList" gvim.exe ""
WSHShell. RegDelete "HKEY_CLASSES_ROOT" * "shellex" ContextMenuHandlers "gvim ""
WSHShell. RegDelete "HKEY_CLASSES_ROOT" * "Shell" edited with & Vim ""
WSHShell. RegDelete "HKEY_CLASSES_ROOT" * "Shell" Edit with Vim ""

Dim gvimpath
Gvimpath = WSHShell. RegRead ("HKEY_LOCAL_MACHINE" SOFTWARE "Vim" Gvim "path ")
WSHShell. RegWrite "HKEY_CLASSES_ROOT" * "Shell" Edit with Vim "", "With Vim (& F )"
WSHShell. RegWrite "HKEY_CLASSES_ROOT" * "Shell" Edit with Vim "command "",_
Chr (34) + gvimpath + Chr (34) + "-p -- remote-tab-silent" + _
Chr (34) + "% 1" + Chr (34), "REG_SZ"

 

Next, double-click the vim. vbs file.

OK. Now you can right-click the file you want to open and see the "Edit with Vim" item? Select this option to open the file on a new Vim tab.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.