Search code examples
gitgit-diff

Any way to set vim's colorcolumn in git diff?


In vim, I can use set colorcolumn=80 to highlight the column 80.

I need same functionality in git diff, any way to do this?


Solution

  • You can try using vim (vimdiff) using this command:

    git difftool --tool=vimdiff --no-prompt
    

    If this is something you like, you can configure git to always use vim as its difftool and merge tool:

    git config --global diff.tool vimdiff
    git config --global merge.tool vimdiff
    git config --global difftool.prompt false   
    

    Once you're using vimdiff, familiarize yourself with common actions:

    ]c :        - next difference
    [c :        - previous difference
    do          - diff obtain
    dp          - diff put
    zo          - open folded text
    zc          - close folded text
    :diffupdate - re-scan the files for differences
    

    You'll gain all the niceties of vim (coloring, macros, modal editing) but you'll be in a specialized mode of vim designed for diffs and merges.