Highlight CursorLine in Vim - vim

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.

Related

Get rid of the underline in Vim's fold name

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

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.

MatchParen and cursorcolumn conflict

Vim is not showing the matching brackets on the same column when I do in _vimrc
:set cursorline
:set cursorcolumn
Actually I have in my _vimrc
:set cursorline
:set cursorcolumn
:highlight CursorLine term=underline guibg=#fffcd0 cterm=underline
:highlight CursorColumn term=underline guibg=#e1ffd5 cterm=underline
Then the matching bracket on the same column does not highlight.
I tried below playing with guibg and guifg with Black and Cyan and gui=inverse as:
:highlight MatchParen guibg=somecolors guifg=othercolor gui=inverse
But nothing works.
I need the highlighted current column as #e1ffd5 and current line as #fffcd0, and
the matching brackets highlighted.
I need the both. How can I?
Normally if you do not turn on cursorline and cursorcolumn then there will be no problem, vim will show every matching paren normally, like:
image01.
All the problems will take place if you turn on cursorline and cursorcolumn. The matching paren highlight on the same column at the other end will be vanished, like:
image02.
Finally I tried
:highlight MatchParen guibg=Black guifg=Cyan gui=inverse
But this also is not very perfect. Paren on the other side will fade into white, which I never want.
I want everything perfectly, better saying a mixture of picture 1 and 2 both.
I tried but I could not.
Setting ctermfg and/or guifg to NONE gets you what you want.
hi CursorColumn cterm=NONE ctermbg=236 ctermfg=NONE gui=NONE guibg=#2d2d2d guifg=NONE
hi CursorLine cterm=NONE ctermbg=236 ctermfg=NONE gui=NONE guibg=#2d2d2d guifg=NONE
With the cterm settings I found the following.
First I found that the following command made the matching paren disappear.
:hi MatchParen cterm=NONE ctermfg=black ctermbg=white
While my cursor was on these pren, I switched over to next vertical split, and saw that the colors of the matching peren were reversed.
That led me to the solution with the following command.
:hi MatchParen cterm=reverse
or
:hi MatchParen cterm=reverse ctermfg=<your color> ctermbg=<your color>
I think the color you are looking for is
(steelblue and black) or (black and steelblue)
My setting and I didn't change :hi cursorcolumn.
:hi MatchParen cterm=reverse ctermfg=NONE ctermbg=NONE

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 keep the fgcolor of SpecialKey when :set list

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.

Resources