Scott
Scott

Reputation: 2676

LaTeX, conceal and weird coloring

I have vim, and like the Tex conceal option. Specifically, if I have let g:tex_conceal="sabgm" in my ~/.vimrc, whenever I type $\beta$, I see β. But, after switching color themes, I get some weird output:

bad-highlighting

Upvotes: 6

Views: 2226

Answers (2)

Scott
Scott

Reputation: 2676

As found here, you have to have hi Conceal guibg=White guifg=Black (or similar) in your ~/.vimrc.

good-highlighting

edit 2020-07-19 I've since written a blog post titled "Vim syntax highlighting for Markdown, Liquid and MathJax." It walks through a method to provide Latex and Liquid highlighting for Jekyll. It's pretty easy to adapt for only Latex:

# eg inside .vimrc
function! MathHighlight()
    "" Define certain regions
    " Block math. Look for "$$[anything]$$"
    syn region math start=/\$\$/ end=/\$\$/
    " inline math. Look for "$[not $][anything]$"
    syn match math_block '\$[^$].\{-}\$'

    "" Actually highlight those regions.
    hi link math Statement
    hi link liquid Statement
    hi link highlight_block Function
    hi link math_block Function
endfunction

" Call everytime we open a Markdown file
autocmd BufRead,BufNewFile,BufEnter *.md,*.markdown call MathHighlight()

Upvotes: 4

Utkarsh Verma
Utkarsh Verma

Reputation: 202

Here's what worked for me. Add hi clear Conceal at the bottom of your .vimrc.

Upvotes: 5

Related Questions