Changing background colors - vim

Okay, I'm rather new to vim. I couldn't figure out how to change background colors. I'm editing my vimrc file to set these colors, but I couldn't find anything for background colors.
I'm using a color scheme and I just need to know how I could override it or what is to look for so I can change it in my colors/theme.vim file. I need to change two background colors. I point to them in the image attached.

As it turns out the big blue section is controlled by highlight NonText
I added my .vimrc file to this:
highlight NonText ctermfg=59 ctermbg=0 cterm=NONE guifg=#414e58 guibg=#232c31 gui=NONE
and that gave me exactly what I wanted.

VIM has some color scheme, which store under /usr/share/vim/vimcurrent/colors, and it named as desert.vim for example.
you can simply add one line in your vimrc file, which should be locate in your $HOME, if there is NOT, you can create one, and add:
colorscheme desert
also some command you can use to set the background color like:
set background=light
or
set background=dark
I think for SSH, light is better:) If you use X windows, I suggest to use bensday.vim, it can be download from web

Related

How to change specific 'theme' colors in vim

I would like vim to roughly match the color scheme of a python file in textmate. Here is a comparison of the two:
For example, I want a comment to be blue instead of red. If I have the hex codes for each of these colors, is there a place that I can change this in the vimrc or somewhere else? For example, how would I pass a hex code into the vim colorscheme:
" syntax highlighting
hi Comment cterm=NONE ctermfg=#ddd gui=NONE guifg=#ddd
hi Constant cterm=NONE ctermfg=DarkGreen gui=NONE guifg=green3
I was able to achieve what you wanted in two different ways, the first one was much simpler, I just added
hi Comment guifg=#ddd
into my vimrc just after the colorscheme [colorscheme name].
The second method is better for a big amount of changes and it's much harder. It bases around changing your colorscheme. You would do as follows:
Check what's your current colorscheme, by typing the command :colorscheme while in vim. if it's one of the defaults (blue.vim, darkblue.vim, default.vim, delek.vim, desert.vim, elflord.vim, evening.vim, industry.vim, koehler.vim, macvim.vim, morning.vim, murphy.vim, pablo.vim, peachpuff.vim, ron.vim, shine.vim, slate.vim, torte.vim, zellner.vim), then you need to go to $VIMRUNTIME/colors and edit which is yours. Otherwise check your ~/.vim directory for "colors" or search where you store plugins for the name of your theme. For example if you use vim-plug then plugins and themes are stored in ~/.vim/plugged. Copy the folder to not mess up the original theme and use a different name.
2.After opening the folder of your theme open the only file in it - [theme].vim and search for the item you want to change, e.g. "Comment", change the hex value of the color, background etc.
Repeat to your liking to the time you'll get your theme looking how you want it to.
Set your colorscheme via colorscheme [name-you-picked-earlier]
The second option is also useful for creating full themes suited just to you.

How to make comments Italic in gVim?

I am fairly new to Vim and mainly use gVim for most of my coding purposes. I am trying to figure out what to add in my _vimrc (in windows) to make my comments italic.
I tried adding
highlight Comment cterm=italic
but that didn't work. My modifications so far in my vimrc (if it matters) is:
color slate
set number
set nowrap
set guioptions+=b
if has('gui_running')
set guifont=Consolas:h10
endif
So what can I do so that my comments appear in italics (consolas, italic, size 10)?
The cterm definition is only for high color terminals; for the GUI, you need to use the gui= argument:
highlight Comment cterm=italic gui=italic
Also, put this after the :colorscheme command in your ~/.vimrc, or else it might get overridden.

Vim - Force extra spacing between lines for underlining

While using Vim for most of my coding, I typically prefer to have the current line under-lined so it's easier to see where I am in my code. I avoid using things like line-highlighting because it usually makes things harder to see with my bright-text-on-dark-background theme (ie: 'torte' colorscheme).
Here is part of my Vim colorscheme:
hi CursorLine guibg=#0F2130 ctermbg=NONE cterm=underline
hi CursorColumn guibg=#0F2130 ctermbg=darkgray cterm=NONE
I then enable these features in my .vimrc file (ie: ~/.vimrc).
So, in my case, the current line has a colored underline which is the inverted color of the character above it, while the current column has a dark-grey background, while all other text just has a black background.
The only problem I am having here is that I cannot see underscore ('_') characters while coding because the underline for the current line is the exact same color and thickness as the underscore characters. The only workaround, if its even possible, that would make sense here is to:
Increase the spacing between lines
Make the underline appear a few pixels further below my text
Is anything like this possible in Vim (not gVIM)?
Thank you.
If you are using gVim:
:hi! def link CursorLine SpellBad
It will use curl-underline.
Changing the linespace to 10+ will display _ above the Cursorline:
:set linespace=10
#kev: +1; It works in gVIM
However, it seems this just can't happen in Vim, as other commenters have noted.
In the end, I just set the background to be dark grey (ie: ctermbg=253), and then set the cursorline to be darker (ie: ctermbg=black cterm=NONE).
From there, I updated my BASHRC file to contain the following:
export TERM=xterm-256color
This, of all luck, ends up looking better than my previous colorscheme. I now have a modified version of the standard "slate" color scheme with a very dark gray background (ie: ctermbg=253) while the current line has a solid black background.

Setting the Vim background colors

When I try to change the background colors in .vimrc or directly in Vim using the command:
set background=dark
... it doesn't affect my background at all. Neither does the light option. However, it looks okay when I run gvim.
Is there a way to change the background in Vim without changing my Konsole settings?
EDIT Okay, there is a difference between guifg/guibg and ctermfg/ctermbg. While the GUI accepts lots of different color combinations, cterm allows only few standard ones.
As vim's own help on set background says, "Setting this option does not change the background color, it tells Vim what the background color looks like. For changing the background color, see |:hi-normal|."
For example
:highlight Normal ctermfg=grey ctermbg=darkblue
will write in white on blue on your color terminal.
In a terminal emulator like konsole or gnome-terminal, you should to set a 256 color setting for vim.
:set t_Co=256
After that you can to change your background.
Try adding
set background=dark
to your .gvimrc too. This work well for me.
Using set bg=dark with a white background can produce nearly unreadable text in some syntax highlighting schemes. Instead, you can change the overall colorscheme to something that looks good in your terminal. The colorscheme file should set the background attribute for you appropriately. Also, for more information see:
:h color
supplement of windows
gvim version: 8.2
location of .gvimrc: %userprofile%/.gvimrc
" .gvimrc
colorscheme darkblue
Which color is allows me to choose?
Find your install directory and go to the directory of colors.
in my case is:
%PROGRAMFILES(X86)%\Vim\vim82\colors
blue.vim
darkblue.vim
slate.vim
...
README.txt

VIM initial settings: change background color for line number on the left side?

I use _vimrc to configure my vim 7.2 (windows) default settings. One setting "set number" will display line numbers on the left side. My vim background color is white (I cannot find setting for this. Maybe the default is white. Anyway I accept this setting).
I would like the background color for line numbers to be Grey or dimmed color. What is the command I can put in my _vimrc to configure this default setting?
highlight LineNr ctermfg=grey ctermbg=white
To make the line number column transparent (the same color as the main background) you can try setting this in your .vimrc:
highlight clear LineNr
You can also clear the so-called sign column (used by gitgutter, etc) as well:
highlight clear SignColumn
This way, no matter what color scheme you use, both columns' background will be compatible.
In my _vimrc, here is the setting:
highlight LineNr guibg=grey
or
hi LineNr guibg=grey
I don't need to set fore-color, the default is yellow and it is OK for me.
guibg and guifg are for vims which are not in terminal. For terminal you use ctermfg ctermbg. Usually in GUI vims you have more colors support and you simply want to avoid the background.
So I usually use this:
highlight LineNr guibg=NONE

Resources