Making Vim Syntax Highlighting Work Inside Git Bash

2014-07-28

Dmitry Boychev

Making Vim Syntax Highlighting Work Inside Git Bash

How to fix Vim syntax highlighting not working in Git Bash by linking to standalone Vim installation.

If you have used Git Bash and its Vim, which both come as one package, you have probably stumbled on the issue of making syntax highlighting work.

Whenever you type the command “vi file_name” in Git Bash and type some php code, you will see the plain white text on the black background. To try and fix the issue, you would just type the command ”: syntax on”, because it always worked, right? Well, not so much with the Git Bash Vim scenario.

The fix:

  1. Install Vim separately
  2. Go to Git/bin directory and edit the vim and vi files (by default: C:\Program Files (x86)\Git\bin)
  3. Replace “/share/vim/vim74/vim” with the directory of where you installed your Vim (by default: “C:/Program Files (x86)/Vim/vim74/vim”)

The ”: syntax on” and ”: syntax off” commands will work fine now.

Of course, the ultimate and easiest solution is just to install a linux VM and ssh to it.