PowerShell, vim and aliases vs. *.cmd (when using git)
I have a weird problem. I am using vim as my in-console text editor in PowerShell. That works very well so far and I don't really have an issue with that.
Previously I had vim set up with a batch script (vim.cmd) in a PATH-accessible folder, that simply calls the vim.exe, like this:
@echo off
"C:\Program Files\vim72\vim.exe" %*
Then I told git to use the editor vim.cmd
. That worked fine until I noticed that git has problems with executing batch when using interactive rebase.
So instead, I tried to make vim
an alias in my PowerShell console instead:
Set-Alias vim "C:\Program Files\vim72\vim.exe"
Then I told git to use the editor vim
instead. This works very good, for both normal commits as well as interactive rebasing etc.. However I noticed something stra开发者_JAVA百科nge when using that:
It seems that either of those possibilities does not respect vim's settings correctly. When I make a commit, and git wants me to enter a commit message in git, I see two different appearances and behaviours of vim; although in both instances the same settings should be loaded (is there a way to check that actually?).
The following two screenshots show the differences in both editor setups:
What exactly is the reason for this, and is there a way to fix this? I would actually like to keep the alias version with the line break behaviour (and the disabled statusbar) from the other one; but understanding this is actually more important to me..
Thank you!
Doh! Thanks to Doon for that comment, that actually made me realize it.
When using vim
as git's core.editor
value, that doesn't make git use the PowerShell alias at all. Instead, git calls vim
from inside of its own bin
directory, which does contain a file named vim
with the following contents:
#!/bin/sh
exec /share/vim/vim73/vim "$@"
So actually git is opening that vim instance which is shipped with Git itself and runs that instead. And there, of course my personal settings from my system's vim are missing.
After renaming the alias to something else for a moment and trying it, it turns out that git isn't able to use that, so I guess I'll just change that vim shell script inside the bin
directory to point to my installation and copy some of the changes over to have my wanted effects.
Edit
Seems that from inside the /bin/
directory, git is unable to go outside of itself. So a folder parallel to the git installation is not reachable from within git's shell interpreter..
Guess I'll need to move my vim installation inside of the share directory then.. Good that all my other tools can easily work with a different vim location <_<
精彩评论