VIM: Underline enclosing parentheses - vim

I know i can highlight matching parentheses in VIM.
Is there a way to underline enclosing parentheses like Sublime does?
Only the 2 parentheses around the cursor without having the cursor on one of them. Example:

Assuming the default plugin for highlighting matching parentheses is enabled, then it should be as simple as adding a few styles to the MatchParen highlight group:
highlight MatchParen term=underline cterm=underline gui=underline
More help on the highlight command:
:help :highlight

Highlights the pair surrounding the current cursor position.
https://github.com/Yggdroot/hiPairs

These plugins highlight the pair of parentheses surrounding your current cursor position:
https://github.com/justinmk/vim-matchparenalways
https://github.com/Yggdroot/hiPairs
ShowPairs

Related

Highlight word or line in Gvim

I want to mark some words in "Gvim" by color and can't find in "Gvim" manual how to do it.
How can I highlight word/line in "gvim" when I standing on it?
You can use the :highlight and :match commands. For e.g., if you want to highlight a word deadline then do the following:
:highlight DeadlineGroup guifg=#f234f1
:match DeadlineGroup /Deadline/
The first command (:highlight) will create a highlight-group (:help highlight-groups) and the second (:match) will map a regex with that highlight-group.

Vim higlight : multiple values to a key

I want to make vim not only bold my current line but also to underline it.
My current .vimrc looks like this:
hi cursorline term=bold cterm=bold guibg=Grey40
set cursorline
is it possible to add a value to my cterm?
Something like
cterm=bold&underline
OR
cterm=bold cterm+=underline
Thanks
You should use a comma:
cterm=bold,underline
as explained in :help attr-list:
attr-list is a comma separated list (without spaces) of the
following items (in any order):
bold
underline
undercurl not always available
reverse
inverse same as reverse
italic
standout
NONE no attributes used (used to reset it)

Set vim bracket highlighting colors

I'm using :set showmatch to highlight the matching bracket or brace when the cursor is over one.
I'd like to change the highlight-color so that it's radically different from the cursor color, because I've got the situation shown in the screenshots.
When the cursor is over the second brace:
and when the cursor is to the immediate-right of the brace:
This uses my terminal color scheme, which is taken from Solarized. Unfortunately, it's a bit of a pain to see which highlight is the brace matching and which is the cursor, when the braces are close together.
Is there a vim setting I can use to change the color of that to, say, the bold magenta ANSI? I'm not particularly interested in remapping my ANSI colors within the terminal or shell - I'd like a vim-specific option, if it exists.
you can change the colors to, e.g., blue over green
hi MatchParen cterm=none ctermbg=green ctermfg=blue
just put it in your vimrc file.
basically, cterm determines the style, which can be none, underline or bold, while ctermbg and ctermfg are, as their names suggest, background and foreground colors, so change them as you see fit.
for your case, you may want
hi MatchParen cterm=bold ctermbg=none ctermfg=magenta
I'm using the vividchalk color scheme with macvim, and none of the various solutions I tried worked for me. But I searched the file:
~/.vim/colors/vividchalk.vim
for MatchParen and I found this line:
call s:hibg("MatchParen","#1100AA","DarkBlue",18)
I commented out that line, then I copied that line, and I changed it to:
call s:hibg("MatchParen","#FF0000","Red",18)
which succeeded in highlighting the matching parenthesis in red, which is a LOT easier to see. I hope that helps someone else.
If you want to briefly jump to the opening bracket/paren/brace when you type the closing bracket/paren/brace, then adding:
set showmatch
to ~/.vimrc worked for me.
A very handy trick is setting the cursor on a bracket/paren/brace and then typing % to jump to the matching bracket/paren/brace. That is especially useful when the matching bracket/paren/brace has scrolled off the page. Typing % a second time will jump back to where you came from.
Try :!ls $VIMRUNTIME/colors these are default color schemes Vim supply. Than change color scheme :colorscheme name find color scheme that You like and copy color scheme :!cp $VIMRUNTIME/colors/<name>.vim ~/.vim/colors/new_name.vim edit it and set with color scheme command or better add colorscheme name to vimrc file. After changes to color file :colorscheme name reloads Vim's colors. It's handy :vsp vim, edit colors file in one half, check changes in other. I used nye17 answer and add hi MatchParen line to my color_file.vim it work's just fine.
Links:
Vim help
How to control colors
About Termianl colors
The colours that I use for vim highlighting, (from my ~/.vimrc):
" set sensible highlight matches that don't obscure the text
:highlight MatchParen cterm=underline ctermbg=black ctermfg=NONE
:highlight MatchParen gui=underline guibg=black guifg=NONE
NONE uses the character colour from the
:colourscheme ron (or which ever you prefer from :!ls $VIMRUNTIME/colors )

In Vim can you stop the color change of white space characters with 'set cursorline' on?

In this Vim screenshot you can see that when moving the cursor over a line it changes the normal color of the whitespace characters (shown on the left) from grey to black. Can I stop this and leave them showing grey always, regardless of cursor position?
I've tried setting these in the colour scheme but no luck:
hi SpecialKey guibg=bg guifg=#CCCCCC gui=none
hi NonText guibg=bg guifg=#CCCCCC gui=none
You can use :match to highlight the tabs.
:match NonText '^\s\+'
That seems to override the cursor line. It would be better of course to use matchadd() but it seems to be overriden by the cursor line. There might be a way to make it work
Following lines in .vimrc fixed the problem for me.
au VimEnter * call matchadd('SpecialKey', '^\s\+', -1)
au VimEnter * call matchadd('SpecialKey', '\s\+$', -1)
It overrides other styles application for tabs and trailing spaces inside a cursor line.
Yes you can. From :help listchars (at the end):
The "NonText" highlighting will be used for "eol", "extends" and
"precedes". "SpecialKey" for "nbsp", "tab" and "trail".
With this knowledge you can modify your color scheme accordingly or add a call to highlight in your vimrc.
I believe you have 'cursorline' set. The CursorLine highlight group defines the highlights for the same. Either you set nocursorline, (which can speed line movements) or change the CursorLine highlight groups fg colors.

CursorLine highlight in ViM, highlight only line number and spaces/tabs on beginning /end of the line

I use ViM's :highlight CursorLine to change bg color on the current line. But sometimes the text not readable.
I would like a highlight that could only change the background color for the whole line except the text (counting the spaces/tabs in between chars as text).
Is it doable? If yes, how?
As for as I know, there might be no direct support of setting how the cursorline is highlighted.
But, I've got a trick for doing what you want. That is, after we highlight the cursorline, we can change the color settings of heading/trailing spaces in a line as current "background" and "foreground".
:match NoHighLight /^\s\+|\s\+$/
:highlight NoHighLight guibg=background guifg=foreground
A obvious drawback is the part from "the end of the line" to "the boundary of the vim window" will still be painted as the color of cursorline's setting. If it is ugly for you, you can just change the highlight setting of cursorline by only setting its guifg, like:
:highlight CursorLine guifg=red guibg=background
Maybe there are other neat solutions existed, but that is what I can come up with now. :)
Hope that helps a bit.
I have found a solution -
With regard to #Zhaojun's answer: it's not what I wanted (also /^\s\+|\s\+$/ doesn't do much, maybe it should be /^\s\+\|\s\+$/)
The solution I found is (just example color for elflord color scheme)
:highlight CursorLine gui=none guibg=grey10
:set CursorLine
:highlight NoHighLight guibg=background
:match NoHighLight /\S\+\(\s\+\|$\)/
it's however not working well for trailing spaces at he end of line, but I usually delete them
to make them visible I use the following
:highlight EndSpaces guibg=green
:match EndSpaces /\s\+$/

Resources