Load different colorscheme when using vimdiff

vimdiff color scheme list
vimdiff colors meaning
vim color schemes
vim install color scheme
vim set color scheme
vim c++ color scheme
how to navigate in vimdiff
vim orange

How to load a different colorscheme when doing vimdiff.

I want this because the my current colorscheme does not show some diffs properly in vimdiff, For. eg some diff is shown with same fg/bg color. This makes it very hard to understand the diff. So every time i do a vimdiff i have to do :colorscheme some_other_scheme

Can this be done in .vimrc file?

If you're calling vimdiff from the command-line, put the following in your .vimrc:

if &diff
    colorscheme some_other_scheme

If you're using vimdiff from within vim, you'd either have to override the commands you use to start/stop it (e.g. diffthis, diffoff) using :cnoreabbr (there's also a plugin) or use an autocommand:

au FilterWritePre * if &diff | colorscheme xyz | endif

FilterWritePre is called before filtering through an external program (the diff utility) and the &diff-option is set by vim when it's going into diff-mode (among others, see :help diff)

I'm not sure which autocommand to use to return to the original colorscheme though.

Load different colorscheme when using vimdiff, Question. How to load a different colorscheme when doing vimdiff . I want this because the my current colorscheme does not show some diffs properly in vimdiff​  59. Ctrl+wand right and left arrow can be used to move between any split windows on vim, not only vimdiff splits. These keys do work here on cygwin; also, Ctrl+w walso moves to the next window, but without the delay you mentioned. It is possible that you have mapped these keys in your .vimrc or via some vim plugin.

How do I customize vimdiff colors?, How do I customize vimdiff colors? colorscheme vimdiff. I am trying to use vimdiff as my git merge tool, but the colors used are making it unbearable (  Save vimdiff output? Ask Question Asked 8 years, 8 months ago. Load different colorscheme when using vimdiff. 209. Viewing all `git diffs` with vimdiff. 295.

To answer my own question:

if &diff
    colorscheme evening

vimdiff disable/enable color coding, Difference highlighting, which is the point of vimdiff, still works with this option, but simply as inverse video which is readable here. You can tune with other  As @gszpura said, the default colors suck - and I do agree with him :) I should create a better color scheme based on Selenized palette.

I found the easiest way was to paste this one-liner into my ~/.vimrc file:

" Fix the difficult-to-read default setting for diff text highlighting.  The
" bang (!) is required since we are overwriting the DiffText setting. The highlighting
" for "Todo" also looks nice (yellow) if you don't like the "MatchParen" colors.
highlight! link DiffText MatchParen

design good color scheme for vimdiff · Issue #2 · jan-warchol , As @gszpura said, the default colors suck - and I do agree with him :) I /​2019281/load-different-colorscheme-when-using-vimdiff#2019401 Press F8 to use the next color scheme. Press Shift-F8 to use the previous color scheme. Press Alt-F8 to use a random color scheme. The next/previous/random color scheme selection uses a list of scheme names maintained by the script. The list can be controlled with these commands (the default is all): :SetColors all To use all installed color

If you are encountering unreadable color schemes (not just ugly, but unreadable like white text on pink background), an easy fix may be to use 16 colors instead of 256 colors. Then you don't have to mess with the color schemes.

The reason is that the default vimdiff color scheme assigns DiffChange bg as "LightMagenta", which gets mapped to a very light pink in 256 colors. That is unreadable with white text. With 16 colors, the "LightMagenta" is mapped to a bold magenta, which white text shows up much better on.

You can give a quick test by doing something like this:

vimdiff <file1> <file2>
:set t_Co?    " print current setting (256 by default)
:highlight    " print highlighting scheme
:set t_Co=16  " set to 16 colors
:highlight    " print highlighting scheme

256-color screenshot

16-color screenshot

As you can see, the 16 colors is much more readable, without changing the color scheme.

To make this permanent, you can add set t_Co=16 to your .vimrc

color scheme for vimdiff : vim, There are many color schemes I like, but sadly I haven't found one that looks good while I use vim-sol which is a slightly tweaked version of pychimp/vim-sol. For the replaces (e.g. 7c7), I think vimdiff will put them in side-by-side and color it hl-DiffChange (e.g. purple in my default setting), and then highlight the different text in the line by hl-DiffText (e.g. red in my default setting).

How to set and use a vim color scheme, Using a vim color scheme is actually pretty simple. to make any change to your vim session, try some of the other color schemes listed below,  The colorscheme may use the value of 'background' to adjust its colors, so setting 'background' before loading the colorscheme is the more obvious ordering. (Although note that if you change the 'background' setting, Vim will reload any loaded colorschemes, so setting it 'background' afterwards would also work: it's just non-optimal.)

syntax, If you have multiple files, you can use the filetype as the directory name. All the "*.​vim" If a color scheme is | | defined it is loaded again with ":colors {name}". Molokai is a very nice theme for Vim but it has a terrible vimdiff highlighting (see left split, last 5 lines). + are not green and -are not red. I've been suggested by justinmk@GitHub to use the following ~/.vimrc (here's the gist).

Improve vimdiff syntax highlighting - vim - html, Is this because of my color scheme (currently using Tomorrow Night)? If so, is there a way to How to use different colorscheme and syntax highlighting in vim​? Color scheme for people tired of solarized (16) scheakur: A light/dark colorscheme hybrid: A dark colour scheme for Vim and gVim hybrid-material: Material color scheme based on w0ng/vim-hybrid jellybeans: Colorful, dark color scheme lightning: Light vim colorscheme based on Apprentice lucid: Vivid highlights and friendly, clear colors lucius

  • Is it possible to call more than one command between the two pipes "|"? I would be interested in return to original colorscheme after using vimdiff from vim too...
  • The pipes are substitues for newlines, similar to ; in shell scripts, so you can just add new 'lines': if &diff | colorscheme xyz | cmd2 | cmd3 | endif
  • colorscheme some_other_scheme will look through your runtime paths for color/some_other_scheme.vim. You can see your runtimepaths by :set runtimepath? from within vim.
  • For console users (like myself), I found 'vividchalk' to be the best colorscheme (out of the default install set) for maintaining contrast between highlighted diffs and highlighted syntax, at least for shell scripts. A close second was 'evening.' Hope that helps.
  • My problem is always the lack of contrast with the syntax highlighting, which loses whole chunks of text in diff coloring. I used ':syntax off' as needed in the past, but just added it to my .vimrc in the 'if &diff' predicate and now saved some keystrokes
  • Thanks! This looks much better!
  • Like pabo said in another comment, you may need to name your color scheme file like mycolorscheme.vim, with .vim extension on the end.
  • Thanks! Minor nit: I think you accidentally made all "guibg"s red. Did you intend to have two colors -- one for DiffText and one for the rest?
  • Why when using numbers (ctermbg=17) colors don't work, but when using words ( ctermbg=blue ) - it works ? .. solution: terminal only has 8 colors 1-7
  • MacOS using iTerm2. No matter what I did, I got: Cannot find colour scheme '~/.vim/colors/mycolorscheme' Copying the color codes directly inbetween the "if &diff" statement in ~/.vimrc did the trick.
  • Great color for me!
  • Great solution! I chose Todo instead of MatchParen because it stands out more.
  • Thank's a lot for this tip, even though in my case it was the other way round. t_Co was set to 8, increasing it to set t_Co=256 improved readability tremendously.
  • You wouldn't happen to have a screenshot of the difference this makes?