How to use vim as a git log 'editor?

When I run git log , what exactly is the git log editor used for?

Also:

  • Anyway, can I use vim as my default editor for git log ?
  • If I want to search in git log, what is the best way? Now I am doing something like: git log | grep bla git log | grep bla .
+4
git vim git-log
source share
3 answers

The git log command passes it by default to the pager, and not to the editor. This pager is usually less or more for most systems. You can change the default pager to vim with the command:

 git config --global core.pager 'vim -' 

Now you can search using vim with / , as usual.

+19
source share

You can view viewlog .

It gives you the gui terminal interface for all commits. It will also open the file in the editor of your choice. You can find the corresponding commits using the -grep flag.

0
source share

I wrote a bash script to switch from using vim as an editor to diff-so-fancy.

 VT() { gitlogflag=true if [ -e "$HOME/.myscriptvar" ] ; then gitlogflag=$(cat "$HOME/.myscriptvar") fi if [ "$gitlogflag" = true ]; then git config --global pager.show "vim -c '%sm/\\e.\\{-}m//g' -c 'setlocal buftype=nofile' -c 'set ft=diff' +3 -"; gitlogflag=false else git config --global pager.show "diff-so-fancy | less --tabs=1,5 -RFX"; gitlogflag=true fi echo "$gitlogflag" > $HOME/.myscriptvar } 

I recommend you use diff-so-fancy .

If you just want to use vim, since your git log editor git git config --global pager.show "vim -c '%sm/\\e.\\{-}m//g' -c satisfy you.

0
source share

All Articles