Reload Vim highlight setting and colorscheme - vim

If I change Vim's highlight setting, how do I "reload" it for colorschemes to take effect?
So, in my case, I remove highlight's cursor line number
se hl-=N:CursorLineNr
Changing highlight from
highlight=8:SpecialKey,#:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:Mor
eMsg,M:ModeMsg,n:LineNr,N:CursorLineNr,r:Question,s:StatusLine,S:StatusLineNC,c:Vert
Split,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:D
iffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn,-:Conceal,B:SpellBad,P:Spel
lCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel,x:PmenuSbar,X:PmenuThumb,*:TabLine,
#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine,o:ColorColumn
to
highlight=8:SpecialKey,#:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:Mor
eMsg,M:ModeMsg,n:LineNr,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v
:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffCh
ange,D:DiffDelete,T:DiffText,>:SignColumn,-:Conceal,B:SpellBad,P:SpellCap,R:SpellRar
e,L:SpellLocal,+:Pmenu,=:PmenuSel,x:PmenuSbar,X:PmenuThumb,*:TabLine,#:TabLineSel,_:
TabLineFill,!:CursorColumn,.:CursorLine,o:ColorColumn
(I've emphasized the change.)
But the cursor line number is still "highlighted"!
Changing highlight doesn't update the colorscheme—so how do I "force" an update? I've tried setting syntax coloring off then on again and changing colorschemes to no avail.

If you want to reset/clear a highlight-group, you could use :hi cmd.
in your case, try with:
:hi CursorLineNr NONE #this will disable the hl setting for the given group
:hi clear CursorLineNr #this will set the given group's highlight setting to default.
:h hi to see detail
if you want to reload your colorscheme, you could :color xxx
hope it helps

Related

How to remove highlight group?

I'm trying to remove the jsonCommentError highlight group. On startup I see the highlight group is active by running :hi jsonCommentError.
:hi jsonCommentError
jsonCommentError xxx links to Error
I tried to remove it with :hi clear jsonCommentError and :hi jsonCommentError NONE but this didn't work, and there is no change when I run :hi jsonCommentError.
I guess :hi clear didn't work because the highlight group wasn't added by the user, but I don't know why :hi NONE didn't work.
You can't really remove the group. Only to make it transparent.
hi clear removes group's own highlighting colors. hi link sets group's link target (that always has a preference over group's own colors).
Which one you need, it depends. But it never hurts to do both at the same time:
hi clear jsonCommentError
hi! link jsonCommentError NONE
Also in this case, you may want to switch off all error highlighting at once (see :h json.vim):
let g:vim_json_warnings = 0

Changing background colors

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

Spelling errors hidden while highlighting line in vim

When there's a misspelling (with set spell), it highlights it red (good!), but when the line is highlighted as my current line the red goes away (bad). Removing set cul fixes the problem, but how do I keep the word marked red while being highlighted? I may have multiple words misspelled on a line and also while typing the misspellings are hidden until I go to the next which kinda sucks.
vimrc: https://gist.github.com/OscarGodson/d1b05d52df4ff160b891
colorscheme: https://github.com/tomasr/molokai
1) one could change the vim color scheme, or the SpellBad highlight scheme; one example of the second case is to add in vimrc the following,
hi clear SpellBad
hi SpellBad cterm=bold
2) (not a solution) someone might find 'spell checking while composing' is a bit annoying / distracting and prefer switching the spell checking off until they finish writing the article.
The problem is that the cursorline highlighting has priority over the syntax highlighting (spell errors belong to that), and that cannot be changed. (You can only specify the priority with the newer matchadd() functions.)
I've once raised this issue for error highlighting, but nothing came out of it. (I'd still like to implement a patch for that one day.)
The problem is only about overlap of background highlighting; in GVIM, most color schemes use the undercurl attribute to avoid that issue. In the console, you can only change the highlighting to foreground color, italic or bold attributes to work around it.
workaround
One clever workaround involves swapping the foreground and background colors while adding the reverse attribute: Turn
hi SpellBad cterm=NONE ctermbg=red ctermfg=white
to
hi SpellBad cterm=reverse ctermbg=white ctermfg=red
These two changes cancel each other out normally, but on a CursorLine, the foreground color now contributes to the coloring, turning hard-to-read white-on-cursorline to red-on-cursorline.
Curiously, and jumping off of both answers from the other posters, adding the following in my vimrc made my red background persist accidentally due to my terminal not being able to fulfill the "italic" switch because it can't mix font types like that (I think). I stuck it in the section of my vimrc that is tested for gvim because gvim underlines my spelling mistakes without issue. Give it a try!
if has("gui_running")
#all my gvim settings
else #we're in terminal
hi clear SpellBad
hi SpellBad cterm=bold,italic ctermfg=red
endif

Setting vim omnicompletion colors (Pmenu) in vimrc not working

I am trying to customize my vim popup completion menu as per this guide:
Vim Wiki: "Omni completion popup menu". It notes
add to your vimrc if you always want this choice.
However, with the following settings in my .vimrc file
colo desert
filetype plugin on
set ofu=syntaxcomplete#Complete
highlight Pmenu guibg=brown gui=bold
I get the following:
Note: when I manually enter the highlight command manually, it works:
How do I get the popup to use a color scheme defined in .vimrc without having to enter it in manually each time?
if you put your commands in below sequence, you can get what you want. the syntax option will override your highlight option.
"" gui configuration
color murphy
syntax one
highlight Pmenu guibg=brown gui=bold
See vim - Override colorscheme
Short answer is that you can't. If you use a colorscheme, then all other color scheme tweaks in your .vimrc are ignored. The AfterColors plugin solved the problem for me.
Hmm, most likely there is a highlighting command coming afterwards that is overriding your option. Probably when the filetype is determined and adjusts options. Try running it without the filetype plugin on option set.
If that works, you'll need to adjust the filetype detection to run your special options afterwards.

What are good ways to highlight Tabs with color in Vim on Putty?

I always use putty to connect to Linux machines. I really want to make the Tabs in file visible in Vim.
I can have the Tabs highlighted in Gvim with the scripts below.
syntax match Tab /\t/
hi Tab gui=underline guifg=blue ctermbg=blue
However Vim with Putty, it doesn't work. I try to change gui to cterm, guifg to ctermfg. But still not work.
I know there is other way to make Tabs visible like the scripts below. The tabs will be displayed with ">----". However I don't prefer this way.
set lcs=tab:>-
set list!
Do you guys know any way to highlight Tabs with color in Vim on Putty?
set list allows you to see invisible characters, including tabs.
I added this stuff to my vimrc so that the characters look nicer:
set listchars=tab:▸\ ,eol:¬
The spacehi.vim plugin works for me in Putty connecting to a Linux machine.
The ctermfg and ctermbg options take a color number, not an English color name. Try 9. The table of numbers and their usual meanings is in vim's online help :help ctermfg
A workaround solution is if you do not prefer separate plugin..
Add the following scrpts in .vimrc:
function! HiTabs()
syntax match TAB /\t/
hi TAB ctermbg=blue ctermfg=red
endfunction
au BufEnter,BufRead * call HiTabs()
This will highlight all tabs even in vim help files....
Suggest use spacehi.vim.
Search for the tab special character
/\t
Also make sure Search Highlighting is enabled
:set hlsearch

Resources