Strange TeX syntax highlighting behaviour in vim - vim

I have a bit of a strange problem with [La]TeX syntax highlighting in vim. vim seems to randomly switch between three different syntax highlighting styles, with little rhyme or reason. It doesn't appear to do this for other languages, though I haven't written anything except LaTeX (using syntax highlighting) for a while now.
So: a bit of background. This problem started becoming noticeable when I switched terminal emulators (to urxvt), but it also appears in roxterm, konsole, and gnome-terminal.
Playing around with the value of the TERM environment variable does appear to affect the result: changing TERM from the default of rxvt-unicode-256color to xterm or linux appears to make vim not choose the third, but the first two appear to be selected at random.
I've done some Googling, to no avail. My google-fu is perhaps weak, and I apologize if this is a common problem that I've managed to overlook . . .
For reference, what the three styles look like in a sample document:
Any thoughts or suggestions would be much appreciated.

According to this website, for TeX files, Vim scans the file and guesses whether it is LaTeX, ConTeXt, or plain TeX based on the keywords used therein. Now this is a guess, but maybe every once in a while, while you're editing, you're adding or removing some keyword that is causing it to change its guess each time.

Related

Highlighting and syntax trouble in vim using rmarkdown

I would like to get Vim to stop highlighting list characters (-,*) and heading characters (#) in rmarkdown. You can find a screenshot here: https://imgur.com/a/0YSB8V8.
This is happening when I set the file type to either pandoc or rmd. This is also happening no matter what terminal or colortheme I use.
I have the plugins: vim-pandoc, vim-pandoc-syntax, and vim-rmarkdown installed.
I would like to know a way to make the two characters just appear normally.
I would also like to know if there is a way to make italicized text in tables and headings appear italicized. As far as modifying the appearance of italicized text, I've tried using: hi Italic ctermfg=red cterm=italic in my vimrc, but that does not seem to affect the text in between asterisks (*) in rmd files. I admit I don't know much about the way that syntax works in Vim. Do I need to modify after/ftplugin/rmd.vim or runtime/syntax/rmd.vim? What is the difference between the two?
Any help would be appreciated!
Your syntax highlighter does not seem to recognize the bullet points, but thinks that they mark the beginning of an italic span. Maybe you have a clash of plugins. You could also try another highlighter (e.g. vim-polyglot, supports italics).
vim-pandoc-syntax uses the conceal feature (:h conceal). You can recolor the highlighting group Conceal to change the appearance of the replacement characters.
You can put changes to existing syntax files in .vim/after/syntax/rmd.vim. Files in syntax are executed when they are needed for the first time, but at most once per session. Files in ftplugin are executed every time the file type is changed.

vim colorscheme poor syntax support

I have tried well over 15 different colorschemes for vim. I have made all of the correct settings for full color support in terminal. This 'problem' persists in both terminal and gvim. Perhaps it is not a bug and simply the design of the colorschemes themselves, but only one colorscheme I have tried actually has decent highlight support. For example:
In this python class all of the colorschemes will only highlight a couple of things.
wombat only highlights comments and the if.
molokai is extremly dissapointing but at least gets the ints
All of the themes I try are similar to these two except 'Crayon' which compares like so:
Most of the vim color-scheme github pages show previews with highlight support compared to crayon. My question is what might be causing this problem? or is this just the design of the themes themselves?
Syntax highlighting is the combination of two things:
syntax definition, provided by syntax scripts typically found in syntax/ or after/syntax/,
highlighting definition, provided by colorschemes typically found in colors/.
The former defines syntax groups, the latter defines how those groups look.
But those almost never come in pairs so there's no guarantee whatsoever that every possible syntax group is properly handled by every possible colorscheme.
If a colorscheme you like doesn't handle some of the syntax groups you expect it to handle, open an issue or (better) patch it.

Pair completion in Vim

I do my coding in Vim and recently have been getting more annoyed by its pair completion features. I don't really see the need for pair completion in general as I tend to naturally try to close pairs myself (by pair here I mean type the closing ')' of a set of parentheses, for example). What really annoys me is when I have text already written and to surround it by quotes for example I'll be at the beginning of the word, type ' and then two will pop up right over there rather than just 1 and then me pivoting to the end of the word and typing the other exclamation point. Anyways, that's it for my rant, so any help on stopping my vim from doing this would be appreciated. I use spfvim-13 (https://github.com/spf13/spf13-vim) and have only modified the .vimrc slightly. I wasn't able to pinpoint exactly from where this specific issue arises.
This is not a native vim behavior, it's definitely some plugin causing it. I can't pin-point a particular plugin that spf13 might be having for this, I looked for popular ones I know, like simple_pairs, delimitMate etc.
Best way to investigate what's causing is to just see the output of :verbose imap ' and you'll come to know where it's being set and then remove that plugin / setting.

Mac OSX Terminal Vim displays javascript code with weird and horrid shade

I develop javascript and just recently I found that I still love to use Terminal Vim instead of MacVim. Then I was totally annoyed when I opened my usual javascript file in the Terminal Vim: the statements of the code are irregularly highlighted with a mysterious color.
Just to clarify that other file types I have opened (e.g. c, html etc.) do not have the problem. I have scoured website but I could not find an answer. This is just so unacceptable, could someone help me out. A million thanks!
My .vimrc screen shot:
You appear to be using Syntastic.
The first line with the red background seems to be marked as an error.
The Error highlight group is very often set to use a red background.
My conclusion is that what you see is exactly what you should see. It is ugly on purpose and designed to look like that: you don't want to miss errors, do you?
However, Syntastic can be set to not use the Error highlighting to mark errors but the "signs" feature instead which is a lot less ugly.
You should have read the Syntastic documentation as it is all explained in plain english:
:help syntastic-error-signs
Also, set background=dark is not very useful (it doesn't change the background color, if that's what you want) and can be removed safely from your ~/.vimrc.
I found out that it was this plugin jslint.vim that caused the text to be highlighted. The problem is that this plugin could not be disabled properly which I thought I did. Thanks to the hint of #romaini, syntactic is a better plugin to check code errors and make proper configuration.
As a side note, for those who would like to use vim solarized color scheme, please use the solarized terminal color scheme first. Otherwise the color scheme won't be displayed properly.
Thank you for all of your comments and answers! Really appreciated.
Try changing your colorscheme. Open the file in Vim, then do
:colorscheme blink
To cycle through all possible colourschemes, type :colorscheme, then a space, then press Tab. When you reach a colorscheme that sounds promising, press Enter, and see if the text looks OK. Keep doing this until you find a colorscheme that you like.
Once you have found a colorscheme that you like, copy its name, and put the following in your .vimrc:
colorscheme name
(name is the name of the colorscheme you like.)
My favourite colorscheme is blink, but there are many good ones. You can even go online and download new ones if the defaults are not good enough.
Seems the syntax are not recognized correctly. Could you try:
:set filetype=javascript
One other thing to look at to make things look better (will change colors not highlighting). Make sure that your terminal reports itself as xterm-256colors. You can check this by typing echo $TERM.
If it doesn't return xterm-256colors go to Preferences -> Settings -> Advanced (tab) on the profile you are using.
Change the drop down at the top to xterm-256colors.

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