Is there any way to configure Windows to open text files in Cygwin's VIM instance? I am currently using GVIM but I find it limiting for many reasons. Unfortunately, I can't just install Debian on this machine and be done with it!


If you right-click on a .txt file and select "open with" you should be able to click "Browse" and go to C:\cygwin\bin\vim-nox.exe. Then you can click "Always use the selected program to open this kind of file".

However, I prefer to just have a "native" Windows Vim install and use that.

  • Thank you, that does work. However it opens in a CMD-like window with no access to the Cygwin shell. Is there any way to have it start in a new or existing Cygwin instance? – dotancohen Apr 16 '12 at 20:21
  • That gets trickier, and I don't know if it's possible at all. I suspect that if it is, it would require directly modifying the registry to change the command for the .txt filetype, and I'm not that talented with Windows (it has never been my primary OS). – Heptite Apr 17 '12 at 7:23
  • 1
    For posterity, and my future self: Use cygwin shell. – dotancohen Apr 23 '12 at 3:22

Create cvim.bat file:

@echo off
chdir C:\cygwin\bin
start "" mintty.exe /usr/bin/vim.exe %1

Place it on your PATH and then cvim yourfile.txt or as Heptite has said: right-click on a .txt file and select "open with" you should be able to click "Browse" and go to that cvim.bat. Then you can click "Always use the selected program to open this kind of file".


If you want to open VIM with the mintty terminal, you could use the following set-up:

First create a bash-script with the following:

FILEPATH=$(cygpath -u "$1");

This will convert the windows filepath into a unix-style filepath for cygwin. Place this script (for example) in /bin/native-vim

In regedit (regedit.exe) you should go to HKEY_CLASSES_ROOT/*/shell. Create a new key (rightclick on shell) with as name Edit with VIM. Change the standard value to Edit with &VIM. Create a new key in Edit with VIM with the name command. Change the standard value to C:\cygwin64\bin\mintty.exe -i /Cygwin-Terminal.ico /bin/native-vim "%1" (or the path to your mintty.exe and bash-script).

The changes in your register could also be accomplished with these register-keys:

[HKEY_CLASSES_ROOT\*\shell\Edit with Vim]
@="Edit with &Vim"

[HKEY_CLASSES_ROOT\*\shell\Edit with Vim\command]
@="C:\\cygwin64\\bin\\mintty.exe -i /Cygwin-Terminal.ico /bin/native-vim \"%1\""
  • Thank you very much! I don't have a cygwin environment to test in right now (happily at home in Linux) but as soon as I have to fight with another Windows machine I will try this. +1 in the meantime. Thanks! – dotancohen Nov 27 '14 at 9:32

As long as path to the vim binary is the PATH environment variable, you should be able to run it from any command line like so:

vim filename

If you already have a running instance of vim, try:

vim --remote filename

Since you're using Cygwin, the man page was probably installed along with it. You can view all the options for invoking vim on the command line with:

man vim
  • Thank you Dorian. I did find the path to Cygwin's VIM from Heptite's answer. However it opens in a Windows-environment terminal, not in the Sygwin-environment terminal. Do you know how to open the program in the Cygwin terminal? Thanks! – dotancohen Apr 17 '12 at 15:16
  • Off the top of my head, running the command in Cygwin terminal should work. Otherwise you can do a somewhat complicated invocation of the shell that you use in Cygwin (probaly bash). – Dorian Patterson Apr 18 '12 at 1:20
  • Thanks. I suppose that I could start browsing the Windows directories in Cygwin. I was hoping for a bridge from Windows Explorer (the Windows file manager). – dotancohen Apr 18 '12 at 1:27

Here is the windows_gvim.bat file that I use to open text files with cygwin gvim under Windows. It works for cygwin vim too, just replace gvim with vim.

set "var=%1"
set "var=%var:\=\\%"
C:\cygwin64\bin\mintty.exe /bin/bash --login -c "gvim $(cygpath -u '%var%')"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.