Vim (gvim) automatically opens a file on the new tab

Source: Internet
Author: User
Well, what I'm talking about here is not how to use tabnew in the terminal to open a new tag, but how to use gvim to open a new file in windows, it is opened on the gvim tab by default.
Here there are two main methods, in fact, the principle is the same (that is, gvim executes the command parameters are the same), but there are some differences in the implementation of windows.
1. Use Windows to send messages.
Editors such as emeditor will add their shortcuts to the editor by default after installation. Vim directly uses Vim to edit the shortcut menu, in order not to conflict with the default shortcut, we use this method to enable the new file opening function on the tab.
1) Start-> Run, enter sendto
2) In the pop-up window, right-click and select new shortcut.
3rd, fill in the "Project location" (that is, the path of gvim.exe and the execution parameters) in "done", and enter

"C: \ Vim \ vim72 \ gvim.exe"-p -- remote-tab-silent "% *"

Note: quotation marks must be placed on the path. For example, the default installation path is in c: \ Program.
Files, you need to add quotation marks on the path, that is

"C: \ Program filesvim \ vim72 \ gvim.exe"-p -- remote-tab-silent "% *"

4) enter the name on the vim tab.
5) select two files at the same time, right-click them, and click the vim tab. Haha, OK ~~

In this way, the original functions will not be affected, but the functions we want will be realized.

II. The second method is actually writing a script. In fact, this method is also feasible in Linux, but it is just a shell.
1) create a new batch file, tab_vim.bat
2) write in the file:

@ Echo off
Start/B c: \ Vim \ vim72 \ gvim.exe-p -- remote-tab-silent "% ~ F1"
Exit

3) select this file in the open mode ~~~, Is it very troublesome to choose each time? Don't worry, once you select the file with the corresponding extension, our Bat program will appear directly in the Open Method list ~

OK, that's it ~~

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.