How do I use installed Vim in Git Bash instead of the one that came with Git?
Solution 1
By default Git runs vim from Git\bin\vim
.
This is actually a script that contains path to the executable itself:
#!/bin/sh
exec /share/vim/vim73/vim "$@"
Therefore you can edit this file to point to your Git location.
The default editor can be overridden in Git\etc\gitconfig
:
[core]
editor = path_to_your_editor
Solution 2
Assuming that changing content of C:\Program Files (x86)\{vim,git}
is possible you have at least these two options depending on value of your %PATH%
environment variable:
If you have
C:\Program Files (x86)\vim\vim73
in your%PATH%
you can just removevim
binary that was installed with Git. For this to work Vim should be run asvim
and not by a full path.You probably have your
Program Files (x86)
directory on a NTFS volume, so you can remove Vim executable installed by Git and make a symbolic link to real Vim executable.
Solution 3
If your installation of Vim is available on path, open up Powershell console and execute this:
git config --global core.editor "$(Get-Command vim | % { $_.Source -replace '\\','\\\\' })"
It will set your git editor to Vim that is on path.
Related videos on Youtube
matpie
Updated on September 18, 2022Comments
-
matpie over 1 year
I've installed Vim and Git to
C:\Program Files (x86)\(vim|git)
respectively.When I run Vim from Git Bash, it runs the internal version of Vim that came with the Git installer. Is there a way to override this behavior that doesn't involve changing my
.profile
or.bashrc
or the like so that I can run the version of Vim that I installed in Program Files?Thanks.
-
THBBFT over 7 yearsOn the off chance that somebody comes here after 2012-08-17, the path to the
gitconfig
file on achocolately
git install isc:\program files\git\ningw64\etc\gitconfig
-
matpie almost 7 yearsThat will work within Git. I was looking for an option that will use the system-installed version of Vim within Git Bash.The accepted answer works best still.
-
bazzilic almost 7 years@sirlancelot i think, I misread your question.