How to change the coloring scheme of Gdiff in vim-fugitive plugin? - linux

I use the vim-fugitive plugin to check git diff. The coloring scheme to highlight the code changes does not compliment my solarized background. I am not able to see the commands to change the coloring scheme of Gdif. Could anyone help me changing the coloring scheme?

From :help :diffupdate:
|hl-DiffAdd| DiffAdd Added (inserted) lines. These lines exist in
this buffer but not in another.
|hl-DiffChange| DiffChange Changed lines.
|hl-DiffText| DiffText Changed text inside a Changed line. Vim
finds the first character that is different,
and the last character that is different
(searching from the end of the line). The
text in between is highlighted. This means
that parts in the middle that are still the
same are highlighted anyway. Only "iwhite" of
'diffopt' is used here.
|hl-DiffDelete| DiffDelete Deleted lines. Also called filler lines,
because they don't really exist in this
buffer.
So, for example, something like
:highlight DiffAdd ctermfg=253 ctermbg=237 guifg=#dadada guibg=#3a3a3a
in your colorscheme should change the colour of the added lines.

Related

How to get matching brace highlighting without cursor jump in vim

I am running vim 7.3 on several machines. By default MatchParen is enabled on all of my instances. Using gvim on my windows machine, it is doing exactly what I want - when my cursor is on a bracket, paren, etc. it visually highlights the match. It does not affect cursor navigation. However, on my Ubuntu boxes, when I move the cursor onto the character, it actually jumps to the match.
I'm sure that the behavior is caused by MatchParens because if I do a :NoMatchParen, it stops. Unfortunately, I also don't get the highlighting at that point. I can't figure out where my settings differ, though.
I'll like you even more if you can point me towards a plugin that will always highlight the closest enclosing pair of characters around my current position (like a code oriented version of MatchTagsAlways)
When showmatch is set, the cursor is actually jumping, and the following line fixes the problem:
set matchtime=0
More details:
http://vimdoc.sourceforge.net/htmldoc/options.html#'matchtime'
Just like FDinoff said in the accepted answer, this is probably only a problem of colors.
So if the color of the matching "paren" disorients you, tweaking colors of background and foreground is likely the solution.
But HOW do you do this?? ^^
I've had quite a journey through the vimdoc (it was not easy).
I've tested a whole bunch of variables and found that the relevant tweak is the [hi]ghlight command and specifically the MatchParen group.
The solution
Adding this in my .vimrc did the trick:
hi MatchParen ctermfg=208 ctermbg=bg
Note that vim config files are read from top to bottom, and some types of "words" are matched by several options. For example, a boolean could also be a keyword. Thus you have to pay attention to the order of these options.
How does this work?
My problem was that the background had the flashy color while the foreground had the color of the background of my terminal, which made it really confusing. Thus switching colors was the solution for me. But maybe you will have to tweak it differently.
First, you can check the current value for highlight MatchParen by entering the following command (while inside vim, in normal mode):
:hi MatchParen
You'll see hi MatchParen followed by XXX in the current style, followed by a list of argument=value separated by spaces.
The important arguments are ctermfg and ctermbg for the "terminal" vim, guifg and guibg for the "gui" vim. (Where fg means foreground and bg means background)
You can change a value and see the result in real time. Just put your cursor over a match character and enter the following command:
:hi MatchParen SomeArgument=SomeValue
This will not be saved, so don't worry. When you find a proper combination of values, you can add them in your .vimrc as shown above.
Personally, I set ctermfg to 208 (orange color) and ctermbg to bg (a keyword for the current background color, if known by vim).
If you use vim in a gui, take a look here for the available choice of colors.
The cursor isn't jumping. The color scheme probably has defined bad colors for the MatchParen highlight group which makes it look like the cursor is jumping.
Running default gVim (v7.4.461) without any configuration (i.e. no .vim files) in openSUSE 13.2 Legacy 32 Bit, :set showmatch? reveals that showmatch is on at start, which is not Vim's stated default behaviour. We can account for this by adding :set noshowmatch in our .vimrc.

vim: change line's font color based upon first character in the line?

In vim, I'd like to change a font color for just one line depending on if said line starts (with any preceding tab/space/whitespace) a dash, period, slash, or 'x'. How can I program/configure existing vim to do this?
In Vim, a colorscheme just provides a mapping of highlighting groups (usually generic ones such as Comment, String, though particular syntaxes also define things like vimLineComment) to foreground / background colors and text attributes such as bold or italic. What you want is a custom syntax definition.
:help usr_44.txt introduces writing a syntax file; you can also look to the existing ones in $VIMRUNTIME/syntax/ for inspiration. To highlight lines starting with x:
:syntax match mysyntaxXLine /^x.*$/
:highlight link mysyntaxXLine Error

vim: highlight Folds change only background color

I have commented out the
"hi Fold …
line in my current vim-colorscheme (xoria256 modified), but when I edit there is still (an even uglier) syntax highlight. I looked in the syntax file for the specific filetype - but there was no Fold highlight too. Now I don't know where to look for a "default syntax highlighting".
In the end I just want to have folds with foreground color as specified by syntax and just the background changed. Maybe I am thinking to much and there is a plain easy way to do that.
ps: i tried to leave off the guifg and ctermfg part to no success.
I'm afraid that doing so is not possible (at least without touching Vim's source code). The text in the fold line is computed and not part of your file, which means that it will not be processed like the rest of the text/code and it will be only applied the Folded highlighting group. That's why you get a single foreground color when you comment out the hi Folded line.

Replacing vim colors without inventing color scheme

I don't want to learn how to create a new scheme. I just want to replace some color with another color everywhere in default color scheme.
This is how default.vim (default color scheme by Bram Moolenaar) looks like with comments removed:
hi clear Normal
set bg&
hi clear
if exists("syntax_on")
syntax reset
endif
let colors_name = "default"
As you see it doesn't define any colrs it uses whatever the colors used to be (in C code, I guess).
So, how can I replace some color with another color everywhere?
Example: default color scheme highlights some groups of text with color 'ugly' and I want it to highlight it with colour 'neutral'.
Is question clear enough now?
*:hi-default* *:highlight-default*
The [default] argument is used for setting the default highlighting for a
group. If highlighting has already been specified for the group the command
will be ignored. Also when there is an existing link.
Using [default] is especially useful to overrule the highlighting of a
specific syntax file. For example, the C syntax file contains: >
:highlight default link cComment Comment
If you like Question highlighting for C comments, put this in your vimrc file: >
:highlight link cComment Question
Without the "default" in the C syntax file, the highlighting would be
overruled when the syntax file is loaded.
Here is how to replace a color everywhere in Vim. First, use the :highlight command in vim to view a sample of all the predefined color groups. You should also read the output of :help highlight to see the definitions of all the color highlighting groups.
Once you have identified the group you want to change the a candidate replacement group (with a better color), use a command like this:
" Fix the difficult-to-read default setting for search/replace text
" highlighting. The bang (!) is required since we are overwriting the
" DiffText setting. Use the ":highlight" command in vim to see
" alternate color choices if you don't like "Todo" or "StatusLine"
highlight! link IncSearch Todo " Yellow
highlight! link Search StatusLine " Light tan
" 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" (Aqua) diff color.
highlight! link DiffText MatchParen " Aqua
" highlight! link DiffText Todo " Yellow
The vim help for highlight shows you can also specify colors as hex RGB like:
:highlight Comment guifg=#11f0c3 guibg=#ff00ff
There is also a lot of good information to be found by using :help syntax.
As always, once you have found the colors you like, you should save them in your ~/.vimrc file (saved in Git, of course!) so they are applied automatically every time you fire up GVim.

How do I make vim syntax highlight a whole line?

I'd like to have vim highlight entire lines that match certain patterns. I can get all the text in a line to highlight (by doing syn match MyMatch "^.*text-to-match.*$"), but it always stops at the end of the text. I'd like to to continue to the end of the term, like highlighting CursorLine.
I've tried replacing $ with a \n^, hoping that would wrap it around. No change. (I didn't actually expect this would work, but there's no harm in trying.) I also tried adjusting the syn-pattern-offset (which I read about here: http://vimdoc.sourceforge.net/htmldoc/syntax.html#:syn-pattern). Long story short, adding he=he-5 will highlight 5 fewer characters, but he=he+5 doesn't show any extra characters because there aren't characters to highlight.
This is my first attempt at making a vim syntax and I'm relatively new to vim. Please be gentle and include explanations.
Thanks!
(edit: Forgot to include, this is a multiline highlight. That probably increases the complexity a bit.)
It's not very adaptive as the filename (buffer) and line to full row highlight needs to be explicitly identified, but apparently the sign command can be used:
It is possible to highlight an entire
line using the :sign mechanism.
An example can be found at :help
sign-commands
In a nutshell:
:sign define wholeline linehl=ErrorMsg
:sign place 1 name=wholeline line=123 file=thisfile.txt
Obviously, you should pick a higlight
group that changes the color of the
background for the linehl argument.
source: Erik Falor, vim mailing list
From the documentation on syn-pattern:
The highlighted area will never be
outside of the matched text.
I'd count myself surprised if you got this to work, but then again, Vim is always full of surprises.
could also try
:set cursorline
:set cursorcolumn
change colors like this:
:hi cursorline
:hi cursorcolumn
using the usual term=, ctermfg=, ctermbg= etc
see this answer
VIM Highlight the whole current line

Resources