Vimtab is a Windows batch script that can be used to open files in new tab pages in gVim. Additionally, it can also be used to register a context menu option for files to open them in new tab pages in gVim by right clicking the files.
Vim installer for Windows doesn't create any context menu option for files that lets us open them in new tab pages in an existing instance of gVim. The closest thing it does is create context menu options for files called 'Edit with existing Vim'. This option lets us open a file in a new buffer in an existing tab page in an existing instance of gVim. However, this option does not open a file in a new tab page in an existing instance of gVim. Vimtab fills this gap by creating a context menu option for files called 'Open as new tab in Vim' which lets us open files in new tab pages in an existing instance of gVim. Additionally, the script itself can be invoked from the command prompt to open new files in new tab pages in an existing instance of gVim.
Since this is just a one file script, installing it simply requires downloading the vimtab.cmd file and copying it to some directory present in the Windows PATH variable. To download this script, visit https://github.com/susam/vimtab and click the 'ZIP' button. Then unzip the downloaded file and copy the vimtab.cmd file from it into a directory specified in the Windows PATH variable.
There are various ways to check the Windows PATH variable.
- Hold down the 'Windows' key and press the 'Break' key to launch the 'System Properties'. It can also be launched by right clicking 'My Computer' and selecting 'Properties'. If you are on Windows Vista, Windows 7 or a later version of Windows, click 'Advanced system settings'. Click 'Advanced' tab. Click 'Environment variables' button. Look for the 'PATH' variable in 'System variables' section.
- Open 'Command Prompt' and run the command: echo %PATH%.
Once vimtab.cmd is placed in a directory specified in the Windows PATH variable, it can be launched from command prompt by simply executing the command:
To open a file, say, foo.txt in a new tab page, execute the command:
This opens the file in a new tab page in an existing gVim instance if an instance of gVim is already running. Otherwise, it opens the file in a new instance of gVim.
To enable a context menu option called 'Open as new tab in Vim' for all files so that you can open a file in a new tab page in gVim by right clicking it, execute the command:
Once executed, you should get an option called 'Open as new tab in Vim' when you right click files. For more details on how to use vimtab, execute the command:
When the vimtab command is executed from a 32 bit Console2 window running on a 64 bit Windows operating system, the script fails with this error:
ERROR: The system was unable to find the specified registry key or value.
This issue can be fixed either by executing the vimtab command in native Windows Command Prompt or by installing the 64 bit Console2 application and executing the vimtab command from a 64 bit Console2 window.
This is free software. You are permitted to redistribute and use it in source and binary forms, with or without modification, under the terms of the Simplified BSD License. See the LICENSE.txt file for the complete license.
This software is provided WITHOUT ANY WARRANTY; without even the implied warranties of MERCHANTABILITY and FITNESS FOR A PARTICULAR PURPOSE. See the LICENSE.txt file for the complete disclaimer.
If you do not have a copy of the LICENSE.txt file, please visit http://susam.in/licenses/bsd/ to obtain a copy of the license.