How do I use vim as 'git show' editor?

前端 未结 5 1638
深忆病人
深忆病人 2021-02-08 12:50

all as described in How do I use vim as 'git log' editor? doesn\'t work for git show . I use often

git show HEAD

ctrl+z 

ps 

  PID TTY          TIME CM         


        
相关标签:
5条回答
  • 2021-02-08 13:30

    Here is a Twitter post to solve that problem.

    https://twitter.com/oliviergay/status/179692941063888896

    Using git show with vim and syntax highlighting: vimgitshow() { git show "$1" | vim - "+set filetype=${1##*.}"; }

    0 讨论(0)
  • 2021-02-08 13:31

    can simply use git show bf9f84042 | vim - in edit mod, or git show bf9f84042 | vim -R - in read only mod, without changing gitconfig

    or

    git config --global diff.tool vimdiff using vimdiff as diff.tool, and then git difftool bf9f042 232wf2f to diff

    0 讨论(0)
  • 2021-02-08 13:33

    You can use the following command:

    PAGER='vim -' git -c color.ui=false show
    
    0 讨论(0)
  • 2021-02-08 13:37

    You might also want to use a better diff than just patch syntax highlighting. It allows you to use git show and see the diff for each file in vimdiff. See this answer.

    0 讨论(0)
  • 2021-02-08 13:47

    This worked for me:

    git config --global pager.show "vim -c '%sm/\\e.\\{-}m//g' -c 'set ft=diff' +1 -"
    

    Crazy vim args found here: https://stackoverflow.com/a/17015531/610634

    0 讨论(0)
提交回复
热议问题