Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git commit opens up two editor panes instead of one to enter message

Tags:

git

vi

commit

When i run git commit it opens up 2 vi editor panes instead of one. The top pane is totally blank. The bottom pane is what I expect to see when running git commit. Every time I want to commit I have to close the top pane using :q before I can write my commit message.

Has anyone seen something like this before? What is the solution?

like image 377
krisharmas Avatar asked Jan 13 '15 19:01

krisharmas


2 Answers

I don't know why this worked, but I commented out a line in my .vimrc that changed the colorscheme. colorscheme solarized. Seems to have fixed the problem somehow. I guess the git commit wants to use a vi without customization and for some reason opens up a secondary pane when a different colorscheme is present.


UPDATE:

Fixed by putting the colorscheme solarized line in my .vimrc in an if block to see if it is called by git commit.

Changed .vimrc:

if $_ != 'git commit' 
colorscheme solarized 
endif
like image 167
krisharmas Avatar answered Oct 10 '22 07:10

krisharmas


I believe the issue is that Git doesn't know what editor you want to use, so it runs vi by default, which launches Vim in compatibility mode.

This could also happen with other applications, so you could set the VISUAL and/or EDITOR environment variables (or/as well as the git-specific GIT_EDITOR) in your ~/.bashrc to fix this:

EDITOR=vim
VISUAL=vim

Alternatively, you can configure git itself to use vim:

git config --global core.editor "vim"

like image 45
claviola Avatar answered Oct 10 '22 08:10

claviola