Vim different DiffAdd on two systems - vim

I have two Vim-s versions with same vimrc:
Linux with PuTTY:
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Mar 7 2020 14:11:31)
Included patches: 1-2367
Huge version without GUI.
Cygwin with mintty:
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug 7 2016 16:06:24)
Included patches: 1-2181
Huge version without GUI.
Both have :colorscheme as default, and background=dark.
But :hi for Linux: DiffAdd ... term=bold ctermbg=4, for Cygwin: DiffAdd ... term=bold ctermbg=1. Difference in ctermbg. May be not only these.
I can't find where default scheme set (there is no $VIMRUNTIME/colors/default.vim). I've not found hi set in other vimrc files (/etc/vimrc, $VIMRUNTIME/defaults.vim, etc.). And don't understand what default scheme is.
I have not modified $VIMRUNTIME files, only in $HOME/.vim. Why DiffAdd-s are different?

default is not a colorscheme in the same sense as desert (for example) is. Vim may or may not be installed with its runtime files, among which its built-in colorschemes. In order to still be capable of providing a "default" colorscheme, the styling attributes of default are hardcoded.
That said, DiffAdd had a blue background before the two versions you are using and it still does so there is nothing to see, here.
What is the output of the following command in both Vims?
:verbose hi DiffAdd

#romainl, you are right, you've point me right place. I've downloaded vim-7.4.2181-1-src.tar.xz from Cygwin Time Machine and found in it file vim-7.4-syncolor.patch where vim74/src/syntax.c patched by Cygwin:
diff -up vim74/src/syntax.c.syncolor vim74/src/syntax.c
--- vim74/src/syntax.c.syncolor 2014-04-16 15:10:30.362287904 +0200
+++ vim74/src/syntax.c 2014-04-16 15:12:50.278229744 +0200
## -6840,8 +6840,8 ## static char *(highlight_init_light[]) =
CENT("Visual term=reverse",
"Visual term=reverse guibg=LightGrey"),
#ifdef FEAT_DIFF
- CENT("DiffAdd term=bold ctermbg=LightBlue",
- "DiffAdd term=bold ctermbg=LightBlue guibg=LightBlue"),
+ CENT("DiffAdd term=bold ctermbg=LightRed",
+ "DiffAdd term=bold ctermbg=LightRed guibg=LightBlue"),
CENT("DiffChange term=bold ctermbg=LightMagenta",
"DiffChange term=bold ctermbg=LightMagenta guibg=LightMagenta"),
CENT("DiffDelete term=bold ctermfg=Blue ctermbg=LightCyan",
## -6928,8 +6928,8 ## static char *(highlight_init_dark[]) =
CENT("Visual term=reverse",
"Visual term=reverse guibg=DarkGrey"),
#ifdef FEAT_DIFF
- CENT("DiffAdd term=bold ctermbg=DarkBlue",
- "DiffAdd term=bold ctermbg=DarkBlue guibg=DarkBlue"),
+ CENT("DiffAdd term=bold ctermbg=DarkRed",
+ "DiffAdd term=bold ctermbg=DarkRed guibg=DarkBlue"),
CENT("DiffChange term=bold ctermbg=DarkMagenta",
"DiffChange term=bold ctermbg=DarkMagenta guibg=DarkMagenta"),
CENT("DiffDelete term=bold ctermfg=Blue ctermbg=DarkCyan",
Same result is if find DiffAdd in both binaries, LightBlue (4) and LightRed (1).
The reason is found. Now I am calmed down. Thank you very much, #romainl!

Related

vim remove underline from line number

I upgraded vim (macOS) using brew:
$ brew info vim
vim: stable 8.1.2100 (bottled), HEAD
After the upgrade, the line numbers at the right are underlined, for example, from the attached picture line number 1 appears like 1_____, any idea how to remove the underline?
Happens only when having :set relativenumber
Latest versions defaults to underline: https://github.com/vim/vim/blob/017ba07fa2cdc578245618717229444fd50c470d/src/highlight.c#L256
CursorLineNr term=bold cterm=underline ctermfg=Yellow gui=bold guifg=Yellow
My templates was using only:
hi CursorLineNr term=bold ctermfg=012 gui=bold
The fix was to define cterm:
hi CursorLineNr term=bold cterm=bold ctermfg=012 gui=bold
I found the fix for this in the .minttyrc as this was driving me crazy as well.
There is a setting in there for Term=vt100
Edit the .minttyrc in your home dir and comment out or remove the line
Term=vt100.
Save the file and close the CLI and reopen a new one. The underline should now be gone from vi from then on. I hope this helps.

Linux VIM : Omnicppcomplete + supertab use bash color theme

I use vim with omnicppcomplete and supertab for programming. The dropdown window, which shows possible completions is like pink. How can i change the color for example to my personal bash color theme?
Open your colorscheme.
Find the lines that start with hi Pmenu*.
Edit them to your liking.
If there's no such line in your colorscheme, add the lines below and change the colors to what you want:
hi Pmenu cterm=none ctermfg=White ctermbg=Black
hi PmenuSel cterm=none ctermfg=Black ctermbg=DarkGreen
hi PmenuSbar cterm=none ctermfg=none ctermbg=Green
hi PmenuThumb cterm=none ctermfg=DarkGreen ctermbg=DarkGreen
See :help :highlight for more.

How do I change my Vim highlight line to not be an underline?

In some colorschemes the current line highlighting changes background, in others, like Desert, the current line is underlined.
I want to change the current line highlighting in Desert to use a different background color instead of underlining. How can I do that?
My .vimrc:
set cursorline
highlight Cursorline cterm=bold
Update: .vimrc that solves the issue
colorscheme desert
set cursorline
hi CursorLine term=bold cterm=bold guibg=Grey40
color desert
set cursorline
hi CursorLine term=bold cterm=bold guibg=Grey40
desert is your colorscheme.(should come first)
put it in your ~/.vimrc
This works better (in every terminal) for me.
:hi CursorLine cterm=NONE ctermbg=darkred ctermfg=white
It is setting of color for terminal: background color - ctermbg, and text color - ctermfg. For using in graphical window, add parameters guibg=darkred guifg=white
You can highlight the corresponding column as well, using the command:
:set cursorcolumn
It is useful to toggle highlighting on and off by pressing one key in the editor. Add these line to your vimrc:
:nnoremap H :set cursorline! cursorcolumn!<CR>
typing 'H' will toggle highlighting on and off (Map it to another key if you want)
You can find more info in the article:
http://vim.wikia.com/wiki/Highlight_current_line
for a style similar to the one you get in gvim in the terminal, preserving the syntax highlight:
" first thing is entering vim mode, not plain vi
set nocompatible
" force 256 colors on the terminal
set t_Co=256
" load the color scheme before anything
colorscheme darkblue " or desert... or anything
" the syntax cmd is when the colorscheme gets parsed, i think..
syntax on
" might not be on by default, this enable the cursor line feature
set cursorline
" set the prefered colours, pick one line here only.
" dark grey, better you can get if you don't support 256 colours
hi CursorLine cterm=NONE ctermbg=8 ctermfg=NONE
" light grey, no 256 colors
hi CursorLine cterm=NONE ctermbg=7 ctermfg=NONE
" dark redish
hi CursorLine cterm=NONE ctermbg=52 ctermfg=NONE
" dark bluish
hi CursorLine cterm=NONE ctermbg=17 ctermfg=NONE
" very light grey
hi CursorLine cterm=NONE ctermbg=254 ctermfg=NONE
" yelowish
hi CursorLine cterm=NONE ctermbg=229 ctermfg=NONE
" almost black
hi CursorLine cterm=NONE ctermbg=234 ctermfg=NONE
If you want to turn the underline on use either one of:
:hi CursorLine cterm=underline
:hi CursorLine gui=underline
Otherwise use one of those:
:hi CursorLine cterm=none
:hi CursorLine gui=none
I had a similar problem setting cursorline highlight, but mine was due to the mksession command that I was using to save the session information during vim exit. This session is then automatically restored during program startup, if it's run without any file arguments.
If anyone has .vimrc setup like this, you can add the following to .vimrc to set cursorline highlight correctly:-
function s:SetCursorLine()
set cursorline
hi cursorline cterm=none ctermbg=darkblue ctermfg=white
endfunction
autocmd VimEnter * call s:SetCursorLine()
A bit of explanation as to why this works. Along with various buffer and window information, mksession saves the current colorscheme name. This is restored during program startup through session restoration. However, since the session restoration is typically done after .vimrc has been run (typically using a function invoked through 'autocmd VimEnter *'), the cursorline highlight setting in .vimrc is reset by the default for the restored colorscheme.
The above function, invoked through the autocmd, will be run after all the initialization is complete and therefore successfully sets the cursorline highlight.
HTH.
You must add .vimrc end line:
highlight lineNr term=bold cterm=NONE ctermbg=none ctermfg=none gui=bold
set cursorline
highlight CursorLine term=bold cterm=NONE ctermbg=none ctermfg=none gui=bold
highlight CursorLineNr term=bold cterm=none ctermbg=none ctermfg=yellow gui=bold

How to change VIM underlines colors

I'm an author of a VIM colorscheme (danger.vim) and I'd like to change some colors that I can barely see.
This is how it looks in Solarized:
This is how it looks in my theme:
As you can see, it's hard to see the underlines at import sys. I'd make them probably lighter blue, and bold.
I use the Syntastic plugin to integrate with Pyflakes and JSLint mainly.
I also use Flux, probably a reason why it's even harder to see.
In your colorscheme file at:
hi Error guifg=NONE guibg=NONE gui=undercurl ctermfg=white ctermbg=red cterm=NONE guisp=#FF6C60 " undercurl color
Change the part after guisp to the color you want.
i.e.
hi Error guifg=NONE guibg=NONE gui=undercurl ctermfg=white ctermbg=red cterm=NONE guisp=#FFFFFF " undercurl color
will make the underlines white
edit:
You can make errors bold by change gui=undercurl to gui=bold,undercurl
Seems like Syntastic shows warnings as spell errors, so all I had to do was to define:
SpellBad word not recognized |hl-SpellBad|
SpellCap word not capitalised |hl-SpellCap|
SpellRare rare word |hl-SpellRare|
SpellLocal wrong spelling for selected region |hl-SpellLocal|
In my colorscheme file.

GVim: Different colors of odd and even lines

Can I create color scheme for GVim (MacVim) where odd lines and even lines will have different colors?
A Google search turned this up (I didn't know how to do it, but your question made me curious). Post below.
Got it to work on text files, as follows (on W32)
---- ~/vimfiles/after/syntax/text.vim
hi default Oddlines ctermbg=grey guibg=#808080
hi default Evenlines cterm=NONE gui=NONE
syn match Oddlines "^.*$" contains=ALL nextgroup=Evenlines skipnl
syn match Evenlines "^.*$" contains=ALL nextgroup=Oddlines skipnl
---- $VIM/vimfiles/after/filetype.vim
augroup filetypedetect
au BufRead,BufNewFile *.txt setf text
augroup END
---- ~/vimfiles/colors/almost-default.vim
[...]
hi Oddlines ctermbg=yellow guibg=#FFFF99
hi Evenlines ctermbg=magenta guibg=#FFCCFF
[...]
Notes:
1. filetype.vim in an "after-directory" and with ":setf" to
avoid overriding already-detected "special" .txt files.
With "default" before the highlight name in the syntax
file (but not without it) the colors from the colorscheme
(invoked from the vimrc) are used. (Without a colorscheme,
the "default" colors from the syntax file are still used.)
Haven't succeeded (but haven't much tried) to make it
work for a more complex filetype with an already defined
syntax like HTML
After entering the above changes, Vim must be restarted
for them to take effect.
OK, enough for now, I'm taking a nap.
Best regards,
Tony.

Resources