With :set cursorline and :set list, the characters in the NonText and SpecialKey highlight groups (for example, $ at the end of each line, and ^M produced by Ctrl+VEnter) lose their highlighting when the cursor is on the same line, reverting to the Normal highlight group like any other bland text. This is very confusing and ugly and bad.
These are the relevant highlights in my config:
:hi Conceal term=reverse cterm=none ctermfg=237 ctermbg=none
:hi CursorLine term=underline cterm=none ctermfg=none ctermbg=235
:hi NonText term=reverse cterm=none ctermfg=237 ctermbg=none
:hi Normal term=none cterm=none ctermfg=252 ctermbg=234
:hi SpecialKey term=reverse cterm=none ctermfg=14 ctermbg=23
The problem persists no matter my highlight configuration (including no configuration at all). I know that some highlight groups just always trump others, but syntax highlighting and highlighting from other groups (Conceal, for example) remains intact; is there a way to make NonText and SpecialKey retain their highlight?
As far as I'm aware, no. Bram Moolenaar has said the following on this matter:
There is no solution. [...] The cursorline highlighting needs to overrule the syntax highlighting, otherwise it would disappear in several situations, esp. if the syntax highlighting uses background highlighting.
If you only want to highlight the line number that the cursor is on you can use
hi CursorLineNr term=underline cterm=none ctermfg=none ctermbg=235
hi CursorLine term=NONE cterm=NONE
(vim8)
Related
I am using dracula theme for vim and am not able to get the number pane, that is, the side panel which contains the line numbers, to be displayed in a sort of translucent manner. The preview image shows that it's possible.
How the terminal should look like
(source: draculatheme.com)
How it actually looks
To fix this issue, I think I need to configure some attributes accordingly, but being a beginner, I don't know which ones, therefore any help and guidance would be appreciated.
As a reference, these are my dotvim files.
The background of the line numbers column is set in the colorscheme to NONE for color terminals and #282a36 for GUIs:
hi LineNr ctermfg=60 ctermbg=NONE cterm=NONE guifg=#6272a4 guibg=#282a36 gui=NONE
From there you have three options:
Enable the 'termguicolors' option so that Vim uses the gui* attributes instead of the cterm* attributes.
This is how the screenshot was taken but it will only work in select terminal emulators.
See :help 'termguicolors'.
Edit the colorscheme directly:
hi LineNr ctermfg=60 ctermbg=242 cterm=NONE guifg=#6272a4 guibg=#282a36 gui=NONE
I've chosen 242 arbitrarily but you can choose whatever color you want in this chart
Override your colorscheme in your vimrc:
function! MyHighlights() abort
hi LineNr ctermfg=60 ctermbg=242 cterm=NONE guifg=#6272a4 guibg=#282a36 gui=NONE
endfunction
augroup MyColors
autocmd!
autocmd ColorScheme * call MyHighlights()
augroup END
colorscheme dracula
I am trying to highlight the 80 character column in vim to help me keep my code short.
I've added this to my .vimrc:
" Highlight column 80
if exists('+colorcolumn')
highlight ColorColumn ctermbg=4
set colorcolumn=80
else
au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1)
endif
I've looked at the available colors with :help ctermbg but no matter what argument I use for ctermbg, I get a dark red highlight which is very annoying. how can I change this color?
Many thanks
With an output of
ColorColumn xxx term=reverse ctermbg=4 guibg=DarkRed
you're probably using GVIM, which uses the gui..= definitions. You need (and should always do, unless you're solely using terminal or graphical Vim) add GUI definitions (:h gui-colors has a list):
:highlight ColorColumn ctermbg=4 guibg=blue
Especially if you're switching colorschemes, there may also be left-over attributes from that. It's safer to specify all attributes (see :help :hi):
:highlight ColorColumn term=reverse cterm=NONE ctermfg=NONE ctermbg=4 gui=NONE guifg=NONE guibg=blue
Try for example:
highlight ColorColumn ctermbg=Blue
Hope it helps!
After I upgrade my vim to 7.4 in Ubuntu system, I found that the popup menu is too dark(I have tried many colors schemes like evening, dark...)
Is there any solution?
Well, you could set your own colors in your vimrc (after your colorscheme command).
:help hl-Pmenu lists 4 highlighting groups for the popup menu. If you never used a highlight group before, have a look at some colorscheme files.
A quick & dirty config using all the same colors because I'm lazy:
colorscheme foo
highlight Pmenu ctermfg=2 ctermbg=3 guifg=#ff0000 guibg=#00ff00
highlight PmenuSel ctermfg=2 ctermbg=3 guifg=#ff0000 guibg=#00ff00
highlight PmenuSbar ctermfg=2 ctermbg=3 guifg=#ff0000 guibg=#00ff00
highlight PmenuThumb ctermfg=2 ctermbg=3 guifg=#ff0000 guibg=#00ff00
I use iTerm2 (Build 1.0.0.20130319) and Vim (bin of MacVim Snapshot 66) on top of OS X 10.7.5 as my CLI editing team.
iTerm2:
Color scheme: Solarized Dark
Terminal type: xterm
Minimum contrast: lowest
Transparency: none
Dimming: disabled
Background image: none
Vim:
set t_Co=16
set background=dark
colorscheme solarized
echo &t_Co returns 16.
Generally I do not seem to have issues with a basic setup. But additionally I try to give "NonText" and "SpecialKey" characters a color value avaiable from the solarized color palette (palette can be found here).
highlight NonText ctermfg=0
highlight NonText guifg=#073642
highlight SpecialKey ctermfg=0
highlight SpecialKey guifg=#073642
The strange thing is while the "SpecialKey" group displays the "cterm" color value correctly, the "nonText" group does not. It seems that it displays the value 8 which is used by "ctermbg". As a consequence all "NonText" characters are not visible anymore. Both groups accept the "guifg" values btw.
Am I missing something which could interfere with my setup?
I found a solution on the solarized bugtracker.
This config lets one assign colors to certain elements and groups:
highlight CursorLineNr cterm=none ctermfg=0 guifg=#073642
highlight NonText cterm=none ctermfg=0 guifg=#073642
highlight SpecialKey cterm=none ctermfg=0 guifg=#073642 ctermbg=8 guibg=#002b36
Notice the
cterm=none
which fixes the problem.
Is there a way to highlight only the current line number (in the left hand coloumn) in vim, without highlighting the background of the current line? Ideally, I would Like to make the current line number bold.
There are two groups that determine highlighting of line displayed when &cursorline option is active: CursorLine and CursorLineNR. First is used to highlight the whole line, second for the line number. So to achieve what you want you must
Clear the highlighting of CursorLine: just hi clear CursorLine after any :colorscheme and set background= call.
hi clear CursorLine
augroup CLClear
autocmd! ColorScheme * hi clear CursorLine
augroup END
Set the highlighting of CursorLineNR if it is not set in your colorscheme:
hi CursorLineNR cterm=bold
augroup CLNRSet
autocmd! ColorScheme * hi CursorLineNR cterm=bold
augroup END
(better to check whether it is already set in the colorscheme, maybe it will look better in that case).
You can join both autocommands in one of course.
CursorLineNR has been added relatively recently around version 7.3.488.
You want to look at
:se cursorline
and perhaps even/also
:se cursorcolumn
This is what worked for me:
highlight CursorLine cterm=NONE ctermbg=NONE ctermfg=NONE guibg=NONE guifg=NONE
set cursorline
I'm just using this in my .vimrc after having set the color scheme. Of course you could also set a specific background color but setting all of them to NONE just highlights the line number (i.e. makes it brighter).
I guess you could just use :hi CursorLine cterm=NONE but I just wanted to make sure I'm making everything transparent (gvim included).
With CursorLineNR I was then able to set the foreground and background colors of the highlighted number.
I'm only writing this because for me it worked without any autocommands and it may be what most people require.
You can set cursorline to highlight only the numbers
'cursorlineopt' 'culopt' string (default: "number,line")
local to window
{not available when compiled without the +syntax
feature}
Comma separated list of settings for how 'cursorline' is displayed.
Valid values:
"line" Highlight the text line of the cursor with
CursorLine hl-CursorLine.
"screenline" Highlight only the screen line of the cursor with
CursorLine hl-CursorLine.
"number" Highlight the line number of the cursor with
CursorLineNr hl-CursorLineNr.
And to override your colorscheme use autocmd
So, the following works:
set cursorline
set cursorlineopt=number
autocmd ColorScheme * highlight CursorLineNr cterm=bold term=bold gui=bold
This worked for me to highlight the line number and not the rest of the line:
highlight CursorLineNr cterm=NONE ctermbg=15 ctermfg=8 gui=NONE guibg=#ffffff guifg=#d70000
The help for highlight-groups does not mention an exclusive "number of current line" syntax group, so the official answer might be no.
You may want to take a look in the cursorline option which highlights the entire line, if it helps.