I am on Windows 10. I first installed Git for windows and then I installed posh-git in PowerShell.

Git installed fine into the folder C:\Program Files\Git which included vim.exe in C:\Program Files\Git\usr\bin\.

I can run vim.exe from PowerShell like this:

& 'C:\Program Files\Git\usr\bin\vim.exe' foo.txt

which works fine. But when I do git commit in PowerShell, git brings up vim.exe with the following text:

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Initial commit
# Changes to be committed:
#       new file:   a.txt

If I press i I enter insert mode. The problem is that now the space key does not move the text to the right. It simply moves the cursor to the left and it is impossible to delete the text that is already there:

enter image description here

As can be seen from the above screen shot, the predeclared text cannot be erased. Any idea what is going on?


It's likely that your terminal settings are not correct. Programs designed for Unix systems require the TERM environment variable to be set in order to function correctly. This tells the program's terminal library how to interpret characters that are typed and how to render data properly on the screen.

Values of TERM that folks have seen work with PowerShell in the past, according to some Googling, include cygwin and msys. If you're using the new Microsoft Terminal, you may also be able to use xterm-256color.

If you're not sure how to set an environment variable, here's an article that explains it.

  • Running $env:TERM gives no output. But if it is the TERM variable, why does running vim.exe directly (not indirectly through git commit) work fine? – Håkon Hægland Jul 4 '20 at 18:27
  • 1
    I tried running $env:TERM = 'msys' before running git commit and it actually works! – Håkon Hægland Jul 4 '20 at 18:31

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.