35

I just recently switched over to Mac. On windows I was using git through the msysgit project. When doing a git rebase -i I'm used to get a nice syntax highlighting in vim. I'm missing it badly now that I'm on Mac. How can I get it back?

6
  • Is it syntax highlighted when you do outside of vim?
    – Conner
    Sep 9, 2012 at 21:29
  • 2
    the colors for the git log etc do work, yes. I have git config --global color.ui true
    – Christoph
    Sep 9, 2012 at 21:32
  • Did you not copy your previous Vim config over? Sep 9, 2012 at 21:56
  • msysgitseemed to abstract all those difficulties away from the end user. All the highlighting worked just out of the box so until my first interactive rebase on my new MacBook I didn't even know that something like a vim config does even exist :)
    – Christoph
    Sep 9, 2012 at 22:34
  • as a side note, may i introduce you to vim-fugitive ? github.com/tpope/vim-fugitive (see the screencasts on vimcast.org vimcasts.org/episodes/…)
    – tshirtman
    Sep 9, 2012 at 23:11

3 Answers 3

68

I just figured out all I need is to create a ~/.vimrc file with a line that reads

syntax on
1
  • 3
    you should mark your answer as correct. It helped me for sure!
    – snowe2010
    Mar 14, 2016 at 17:18
0

For me the issue was git was using "vi" instead of "vim". Adding this to my .bashrc fixed it:

export EDITOR=vim
0

You probably need to set up an autocmd in your .vimrc to recognise the appropriate file as a rebase -i temporary:

autocmd BufNewFile,BufRead git-rebase-todo setf gitrebase

Then you just need to use a syntax file ~/.vim/syntax/gitrebase.vim and put in whatever highlighting commands match your preferences such as the one supplied with recents vims: https://github.com/vim/vim/blob/master/runtime/syntax/gitrebase.vim

2
  • I created the .vimrcat ~/ with the line that you postet and also created the gitrebase.vim file at ~/.vim/syntax/ with the content from that link. Then I reopened the terminal and tried it. It doesn't work. Anything I might be missing?
    – Christoph
    Sep 9, 2012 at 22:29
  • Ok, I just figured out all I need is that .vimrc file with a line that reads syntax on
    – Christoph
    Sep 9, 2012 at 22:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.