Color background in Macvim editor - vim

Basically, The background behind the line numbers are darker than the background behind the code, as you can see from the picture below. The background behind the codes has a slightly lighter color than that behind the line numbers. I hope I describe this well enough for you to understand.
I am just wondering what code should I write onto .vimrc file in order to capture the same effect ?

You will need to put the command highlight in your .vimrc followed by certain arguments. To learn about the arguments that highlight takes, type :help :highlight and press Return. This will open the help for the highlight command.
This is the particular format of highlight that you want:
:hi[ghlight] [default] {group-name} {key}={arg} ..
Add a highlight group, or change the highlighting for
an existing group.
See |highlight-args| for the {key}={arg} arguments.
See |:highlight-default| for the optional [default]
argument.
You can find the correct {group-name} to use with :help highlight-groups. As romainl said, the group names for the line numbers at the left are LineNr and CursorLineNr.
And what to put for the {key}={arg} arguments? Well, check :help highlight-args as the help text suggested. The key represents what aspect of the text should be changed (e.g. italic or not, or the foreground color), and the arg represents what it should be changed to (e.g. italic, or bright red). In your case, you want to change the background color, which is controlled by ctermbg for terminals and guibg for GUIs.
Run :highlight Normal to learn the background color you want. You should see something like guibg=grey10. So try setting the guibg (background color in the GUI) of your line numbers to the color grey10 in your .vimrc:
highlight LineNr guibg=grey10
highlight CursorLineNr guibg=grey10
Edit
It sounds like you want to change the code background color, not the line number background color. To do that, write the same command, but use the highlight group that represents normal code instead of the LineNr and CursorLineNr highlight groups that represent line numbers. If you look at highlight-groups help, you can see that the highlight group for code in general is called Normal. So write
highlight Normal guibg=grey
, changing grey to whatever color you want.
If you aren’t sure what color you want, and you just know that you want it to be the same as some other color, run :highlight {group-name} to look up the settings for that group name, and look for the background color key within it. For example, if you want to make the code background color the same as the line number background color, run :highlight LineNr. You will see something like guibg=#242424, which would mean to use #242424 as the color.

You can find LineNr and CursorLineNr listed under :help highlight-groups.
You will need to add/change the corresponding lines in your colorscheme.

Related

How to get the color of some element in Vim and apply it to another element

This is probably a strange question, but I'm trying to change the current line number in Vim to something different from all other numbers in the line number column.
Thing is, I don't want to change it to a specific value, but to the value of some other gui element.
For instance, change the line number colors to the ones of TabLineSel element:
TabLineSel xxx term=bold ctermfg=2 ctermbg=10 guifg=#859900 guibg=#073642
How can I do this in Vim?
Type
:highlight
in Vim. It will show you all the currently defined group with the color/rendering next to it.
I am not sure which one you want to change but I think you are looking to change either the CursorLineNr (only the number) or the CursorLine (the whole line) group.
To find out in which file it is defined :
:verbose hightlight CursorLineNr
Modify the file, copy paste the line next to TabLineSel and relauch VIm.

Vim colorcolumn interrupted when using wrap

When using set colorcolumn=80 in conjunction with set wrap, the colored vertical column is interrupted, since wrapped lines are still considered as one single line. I think a solution might be to highlight columns 160, 240, ... as well, but I don't know enough Vimscript to implement this.
Please have a look at the following .gif animation to see what I mean:
Is it possible to display the colorcolumn as a continuous vertical bar?
It doesn't appear that vim provides a way of doing this by default. However,
the colorcolumn option allows you to specify more than one column to highlight. (in a comma seperated list) So I think this should do what you want:
set colorcolumn=80,160,240

highlight fixed width block background color in vim

I have an input file for a fortran code that needs input text in specific lines and within specific columns. I'd like to highlight the background of these fields when I type them in Vim.
I'm able to either specify a set of rows by
:highlight row ctermbg=green guibg=green
:match row /\%>5l.\%<9l/
or a specific set of columns by
:highlight col ctermbg=grey guibg=grey
:match col /\%>40c.\%<50c/
Is there a way to specify the row and column width for each field and highlight it a different color?
You can combine the line and column restrictions to highlight a block:
:match block /\%>5l\%>3c.\%<8c\%<9l/
Note that \%c matches byte indices, not actual characters. Unless your Fortran code can only contain printable ASCII characters without <Tab>, you'd better match the screen width with \%v (what Vim calls virtual column).
For different matches, you have :match, :2match, and :3match. These are meant for interactive use; if you want to add the highlighting via a mapping, custom command, or autocmd, you should prefer the matchadd() / matchdelete() functions. They are slightly more involved to use, (you need to store the returned IDs to be able to delete them later), but you can use an arbitrary number of them.

vim : Highlight tab with one color and spaces with another ?

How can I highlight tabs with one color and spaces with another in vim ?
I know how to highlight only tabs or only spaces. And I don't know how to select the colors separately for both spaces and tabs.
A simple solution would be to do something like:
:match Error /\t/
:2match Todo / /
Where Error and Todo are highlight groups from :highlight. This is going to take up two of your three matches and will only be temporary.
Theoretically you could use matchadd() or a combination of highlight groups and :syntax match commands in your .vimrc to make this more permanent but your question doesn't really specify if that's what you want.

How do I change the character Vim uses to number blank lines in a buffer?

Currently, when my window is bigger than the buffer being displayed, blank lines beyond the end of file are shown with the ~ characters in the line number column. I would prefer for the line number column for those lines to be blank. Is it possible to make it so?
As of Vim 8.0, the color of the filler line character (~) can be changed indepedently by configuring the EndOfBuffer highlight group:
highlight EndOfBuffer ctermfg=bg guifg=bg
Unfortunately, it is not possible to change the tilde character that
Vim uses to show the lines beyond the end of a file (without modifying
the source code).
A viable workaround is to hide those tildes by configuring the
NonText highlight group, which is used for displaying them,
so that its foreground color is the same as the background one:
:highlight NonText ctermfg=bg guifg=bg
However, this approach is not a complete solution, because this
highlighting group is also used for rendering the list characters
(see :help 'list' and :help 'listchars'), making it impossible to
specify highlighting just for the beyond-last-line markings.
Starting with version 8 (see :helpg Patch 7.4.2213), Vim allows
to highlight the filler lines after the last line in a buffer using
a separate highlighting group called EndOfBuffer:
:highlight EndOfBuffer ctermfg=bg guifg=bg

Resources