jntme
jntme

Reputation: 622

Is there a way of using my .vimrc when doing a git commit?

I have made my .vimrc fitting my needs in a quite cool way and I'm already really used to it. That's why I get always confused when my different shortcut and bindings don't work as they do in the git commit vim.

Is there a way that this will use my normal vim config? Why is this even different from the normal vim? Does that not use my local vim editor?

I have already set vim as standard editor according to this question.

Thanks!

Update

I use Mac OS X Sierra.

:version inside the git vim returns the right file '$HOME/.vimrc'.

Update 2

I'm actually using Neovim. But I set VISUAL to 'nvim' and it still doesn't work.

Upvotes: 7

Views: 1512

Answers (2)

user8234870
user8234870

Reputation:

While working on Windows I had the same issue. The below PowerShell command will set Neo Vim as the default editor for git.

I agree that in the question the OP has asked for MacOS, this will also benefit Windows users.

git config --global core.editor $(Get-Command nvim).Source.Replace('\\', '/')

Remember we need to replace \(backslash) with / (forward slash) in the path.

Upvotes: 0

herrbischoff
herrbischoff

Reputation: 3326

It's probably some unusual system setting, path variable or alias interfering with this. To make Git explicitly pick up a certain editor (Neovim in your case), do the following:

git config --global core.editor "$(which nvim)"

This assumes you are using a Bash-compatible shell and that running nvim directly opens the editor with the configuration you want and are used to.

It works by setting the global Git configuration to use the absolute path to the nvim binary that gets picked up in your PATH.

Upvotes: 8

Related Questions