How can I find out why a character is highlighted in Vim? - vim

Vim has a tonne of highlighting built in, and plug-ins add more. Highlighting is applied for various reasons, including code syntax, spelling, indenting, search, coding errors and standards, and so on. Because there is limited options for highlighting, there are a few highlights that look the same - in particular, code errors, and spelling mistakes are both underlined red (in my colourscheme).
Is there any way of asking vim "What highlighting rules are being applied to the character under the cursor?"

To find out which syntax group causes the highlighting. :syn list shows all active groups, but it's easier when you install the SyntaxAttr.vim - Show syntax highlighting attributes of character under cursor plugin. When you have the name of the offending syntax group, you can investigate where it comes from; (the last lines of) :scriptnames may help.

Related

How do I undo syntax highlighting for special characters in Vim?

The default behavior in Vim is to syntax highlight special characters such as Numbers, booleans, etc. However when working with comments I find this to be a major distraction since Vim is highlighting them by default. I'd like to keep any syntax coloring in a comment to be the same all across the board. (in my case, light gray)
What is the colorscheme or vimrc setting to maintain a a consistent comment color?
Also unlet c_comment_strings does not resolve the issue.
This is not about particular color scheme. This is about syntax matching rule that allows to find strings/numbers even inside comments. So it depends upon a language.
For C/C++ it is governed by existence of c_comment_strings variable (see also :h c.vim). And it is not a true default. That variable either intentionally defined in your vimrc or it comes from standard defaults.vim. In latter case you need to unlet it.
For other languages refer to Vim docs on a particular syntax.

Strange python highlighting using spf13-vim

So I have been using spf13-vim recently, and I have tried changing the default colorscheme, but for some reason when I do I get strange highlighting of words. The highlighting seems to depend on the filetype such that my .txt and .py file will look different.
As an example, the following image shows the highlighting effect on headnode, clusterRun, bwa, and vt. This only occurs when I alter the colorscheme from default. So is there a way to stop this from happening?
You need to find out which syntax group causes the highlighting. :syn list shows all active groups, but it's easier when you install the SyntaxAttr.vim - Show syntax highlighting attributes of character under cursor plugin. When you have the name of the offending syntax group, you can investigate where it comes from; (the last lines of) :scriptnames may help.
If you cannot find the highlighting this way, it may be spell checking; this goes on top of the syntax highlighting. You can list the corresponding highlight groups via
:hi SpellBad | hi SpellCap | hi SpellLocal | hi SpellRare
If you don't want spell checking,
:set nospell
turns it off.
Soap Box
Vim "distributions" like spf-13 and Janus lure you with a quick install and out-of-the-box settings, but you pay the price with increased complexity (you need to understand both Vim's runtime loading scheme and the arbitrary conventions of the distribution) and inflexibility (the distribution may make some things easier, but other things very difficult). Vim is incredibly customizable, using someone else's customization makes no sense.

Macvim subtle comment keywords

Comments keyword are damn highlighted in Macvim/terminal vim and keeps on irritating me. I am not a pro in customizing vim, but really want to get rid of them and have subtle grey keywords
You need to find out which syntax group causes the highlighting. :syn list shows all active groups, but it's easier when you install the SyntaxAttr.vim - Show syntax highlighting attributes of character under cursor plugin. When you have the name of the offending syntax group, you can investigate where it comes from; (the last lines of) :scriptnames may help.
One solution in your case would be linking the syntax groups to the original Comment group, so that the distinction is lost. This can be done in ~/.vimrc:
:hi link FoundSyntaxGroupHere Comment
Comments were highlighted because of vim javascript plugin and by setting following inside .vimrc file, i am able to stop my comments from getting highlighted
let g:javascript_ignore_javaScriptdoc="1

Vim syntax highlighting unwanted words

I have created a syntax file for some AnB-files for vim and while it does load the syntax highlighting and highlight everything I want it to highlight, it seems to highlight some unwanted stuff as well.
The images show both my highlight file and the AnB file and the problem is:
The word "Elgamel", the characters "g" and "h" (any single lower-case letters) and the words "M1" and "M2" (any single upper-case letter followed by an integer) are highlighted with an unwanted magenta color. Anyone knows what to do here? I tried searching for the problem on both google and stackoverflow, but I couldn't find any similar questions (I might not search using the correct terms, though :D)
Syntax file: http://i.imgur.com/bYoAQcu.png
AnB file: http://i.imgur.com/FOtccXJ.png
This looks like error highlighting from the spell checker.
:set nospell
should then turn it off. You can determine which syntax groups get spell checked via :syntax spell, see :help :syn-spell. Usually, you use enable spelling in comments, etc. by added contains=#Spell.
Here's a tip for syntax script development: When you need to find out which syntax group causes the highlighting. :syn list shows all active groups, but it's easier when you install the SyntaxAttr.vim - Show syntax highlighting attributes of character under cursor plugin.
You can use the plugin HiKinkTrace to determine the highlighting group for the offending text, that should help you to narrow it down.

Search highlighting (hlsearch) not working in vim

I have a problem with search highlighting in vim. I have used it before but currently it does not work at all.
I have entered :set hlsearch, which is also in my .vimrc file.
I have entered :set hlsearch? and the result is hlsearch, indicating that I have successfully turned the option on. (right?)
I am running vim and not vi, so that is not the problem.
I have searched around but only found people asking about turning OFF search highlighting.
I would appreciate any input as this has been driving me nuts. Thanks!
Edit: highlighting also doesn't work for spellcheck, so evidently it's something global about highlighting.
When you have problems with multiple highlightings (like search and spell in your case), first check the defined highlightings with
:hi
If any groups are wrong or off, check your :colorscheme, and maybe try another.
In the console, color problems are often related to the number of available colors, a hairy problem. Check with
:set t_Co?
Another good tool for checking problems with individual syntax items is the SyntaxAttr.vim - Show syntax highlighting attributes of character under cursor plugin.

Resources