Blog    Notes   

Vimtab for Windows

Version: 0.1
Author: Susam Pal
License: GPLv3

Download Download

Vimtab is a batch file that can be used to open files in new tab pages in Vim. Additionally, it can also be used to register a context menu option for files to open files as new tab pages in Vim by right clicking the files. Installation and usage details are provided below.

Since this is just a one file script, installing it simply requires downloading the vimtab.bat file and copying it to some directory present in the Windows PATH variable. There are various ways to check the Windows PATH variable.

Once, vimtab.bat is placed in a directory mentioned in the Windows PATH variable, it can be launched from anywhere by simply executing the command: vimtab. To open a file, say, foo in a new tab page, execute: vimtab foo. This will open the file as a new tab page in the same Vim instance.

To enable a context menu option called 'Open as new tab in Vim' for all files so that you can open a file as a new tab page in Vim by right clicking it, execute: vimtab --enable. Once executed, you should get an option like this when you right click files.

'Open as new tab in Vim' context menu

Note that 'Open as new tab in Vim' is the context menu option created with this command. 'Edit with Vim' was created by the Vim installer and it opens the file in a new gVim window. 'Open as new tab in Vim' created by Vimtab, doesn't launch a new gVim window if one already exists. Instead, it opens the file as a new tab page in the existing window.

'Open as new tab in Vim' context menu option can be removed by executing vimtab --disable.

More usage details can be found by executing the command: vimtab --help. The help details are reproduced below for your convenience.

Usage: vimtab [OPTION] [FILE]...

If no argument is specified, Vim is launched. If arguments are
specified and the first argument is not a valid option then they
are assumed to be filenames and passed to the Vim executable. If
an existing instance of Vim is running, the files are opened in
a new tab page in it, otherwise, a new Vim instance is launched.

Note that if multiple files are specified, multiple tabs are not
opened. They are opened as multiple buffers in a new tab.

The -p or --path option may be used to display the Vim executable
that is executed while launching Vim or opening files in new tab.
This is automatically detected from Windows registry. If it is
found to be incorrect, the source code of the script should be
edited and VIM_EXE variable should be set to the correct path.

Options:
  -p, --path      Display the path of Vim being used
  -e, --enable    Enable 'Open as new tab in Vim' option in context
                  menu of files
  -d, --disable   Disable 'Open as new tab in Vim' option in context
                  menu of files
  -h, --help, /?  Display this help and exit
  -v, --version   Display version information and exit

Report bugs to <susam@susam.in>