Who can help me with this problem?
I have this set in my .vimrc:
highlight CursorLine cterm=NONE ctermbg=white
But the cursor line is underlined instead of getting the white background.
If I write as command the setup:
:highlight CursorLine cterm=NONE ctermbg=white
Vim applies the background color and removes the underline as expected.
Why if the command works, the setup in .vimrc not? the other highlights are working.
This is my setting for Vim's folding:
hi Folded term=bold ctermfg=White
How do I get rid of the underline?
For attributes that you don't specify, the :hi command will keep the previous one. So if your colorscheme includes cterm=underline, you need to configure this:
hi Folded term=bold cterm=NONE ctermfg=White
Using
" Customize jshint highlights
hi clear SpellBad
hi SpellBad cterm=underline,bold ctermfg=white ctermbg=black
I was able to customize my jshint SpellBad highlights to the colors I desire when I first open a buffer containing jshint errors. As can be seen here, my background is black and the line with the error is in bold white and underlined. Exactly as I specified using those definitions in .vimrc above.
The problem is, when I switch around between buffers or open a that buffer later again, my custom jshint SpellBad colors no longer apply and I get the "default" colors which I do not want.
Why is this so? And how do I make my custom jshint SpellBad colors stick?
Because your custom highlight settings will be cleared after every :colorscheme commands.
try:
autocmd ColorScheme * hi clear SpellBad
\| hi SpellBad cterm=underline,bold ctermfg=white ctermbg=black
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
I have this in my vimrc:
hi CursorLine guibg=#DDDDDD
hi SpecialKey guifg=#d8a080 gui=italic
set listchars=tab:»\ ,trail:·,extends:»,precedes:«,eol:¶
set CursorLine
set list
When I move the cursor around, the fgcolor of the current line's SpecialKeys becomes black!
How can I keep them #d8a080 and italic?
Probably, your _vimrc is not broken. I tested below.
# cat > foo.vim
hi CursorLine guibg=#DDDDDD
hi SpecialKey guifg=#d8a080 gui=italic
hi Constant guifg=#d8a080 gui=italic
set listchars=tab:»\ ,trail:·,extends:»,precedes:«,eol:¶
set cursorline
set list
^D
# vim foo.vim
I could see the cursorline is fill with lightgray, and "#DDDDDD" (is Constant) is italic.
And, I did below to show SpecifalKey.
:map
v <C-X> "*d
...
I could see <C-X> is italic.