Questions tagged [syntax-highlighting]

Syntax highlighting is the use of colours, size, typeface, or other attributes to visually indicate it has a special meaning and therefore make it easier to understand the text. For example, marking language keywords with a specific colour.

159 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
27 votes
0 answers
1k views

How does `\zs` interact with syntax matches?

Consider the text: foobarbaz First we highlight the regular expression /foobar/: :syntax match Special /foobar/ Next we highlight the regular expression /foobarbaz/: :syntax match Error /foobarbaz/ ...
Rich's user avatar
  • 31.7k
8 votes
0 answers
474 views

gVim - Use different fonts using :highlight

I want to set gVim font size for Comment highlight group. When I set it, it does not do anything (the font is still the same but color changes). My .gvimrc: se guifont=Fira\ Mono\ Regular\ 10 hi ...
jiwopene's user avatar
  • 181
8 votes
0 answers
126 views

Count only words for which Spell is enabled?

I want to count the words in my buffers, but for TeX files, for instance, a lot of words (e.g., commands) shouldn't be counted. I'm aware that there are scripts that do this specifically for LaTeX, ...
dbmrq's user avatar
  • 857
7 votes
0 answers
370 views

.php file makes html text same color as html attributes - how to fix?

The text inside of <p> tags is the same color as the html attributes, so it's hard to distinguish between them. The html inside this .php file is colored (line one of this image) almost ...
alec's user avatar
  • 785
6 votes
0 answers
176 views

How to fix bash highlighting for left shift?

I have a bash function that does some bit-bashing (no pun intended, and I know the shell is not the best language for that sort of thing), but the syntax highlighter in vim is convinced that this: (( ...
Mark Reed's user avatar
  • 226
6 votes
0 answers
69 views

Spellcheck only a part of a word

(There might be an XY problem in the title, I let you judge.) The default dictionary for French sets the (ASCII) hyphen - to be a word character, which is the right thing to do. The issue is that ...
Maëlan's user avatar
  • 263
6 votes
1 answer
365 views

Interactive syntax-highligting: highlight the current region only

Often enough a text file is structured as a collection of blocks or cells of some kind. E.g., slides in a Tex Beamer presentation, bibtex items, function definitions, etc. I wonder if vim can ...
vbond's user avatar
  • 61
6 votes
0 answers
2k views

Syntax highlighting randomly turns off

I use syntastic and split windows heavily in my vim workflow. Lately, syntax highlighting will vanish, seemingly at random, in one of my windows, usually after opening a new split. This happens with ...
Jonah's user avatar
  • 743
5 votes
1 answer
44 views

How can I recursively use syntax inclusion for two languages?

In Vim, I want the syntax \begin{pycode} ... \end{pycode} to syntax highlight the content inside the environment in Python, and the syntax (#TeX r""" ... """) to syntax ...
user202729's user avatar
5 votes
0 answers
3k views

How to make VIM json syntax highlight more readable

Using VIM 8.1 in Ubuntu 20.04.02. ~/.vimrc has syntax on. The file /usr/share/vim/vim81/syntax/json.vim exists. While the syntax highlight for YAML file is comparable between VIM and Visual Studio ...
Polymerase's user avatar
5 votes
0 answers
392 views

How can I test and debug my syntax files?

I'm trying to make a syntax file for Raku. The major challenge I'm running into is that I have no automated means to test that my highlighting works as expected. I have to keep another tab open, ...
littlebenlittle's user avatar
5 votes
0 answers
181 views

Is it possible to use syn match dynamically

I know that syn match can work with the regular expression to do some custom highlight settings. I'm thinking if it can work dynamically. For example, I'm doing a c++ project and I want to highlight ...
Yves's user avatar
  • 1,013
5 votes
0 answers
68 views

How can I make syntax highlighting files more readable and maintainable?

Vim uses regular expressions for syntax highlighting. Often maintaining these can become rather unwieldy. For example: syn match goVarAssign /\v[_.[:alnum:]]+(,\s*[_.[:alnum:]]+)*\ze(\s*([-^+|^\/%&...
Martin Tournoij's user avatar
5 votes
0 answers
618 views

Syntax highlighting: what is the difference between :syntax match and :match?

Simple question -- what is the difference between the two? When I try, for example, to highlight characters on every line after the 80th with highlight link OverLength Error (OverLength being an ...
Luke Davis's user avatar
  • 1,397
4 votes
1 answer
1k views

How to disable semantic highlighting for certain filetypes only?

Using Neovim's native LSP interface, I noticed that semantic highlighting provided by LSP makes things worse for certain languages, so I want to disable it based on filetype. I know about possibility ...
Thunderbeef's user avatar
4 votes
0 answers
41 views

No comment highlighting for long comment at end of file

I made a syntax file with among others a comment region. It should work like the "c" syntax. Starting with /* and ending with */. Syntax: if exists("dbquery_fold") syn region ...
Andy A.'s user avatar
  • 233
4 votes
0 answers
43 views

Color filenames according to $LS_COLORS in vim

I'm writing a simple vim syntax file for random note takings for work. I would like to color filenames according to $LS_COLORS. I can prefix a filename in the notes file with something random, like '·'...
japh's user avatar
  • 41
4 votes
0 answers
160 views

How to make certain conceal symbols get highlighted differently than others?

I’ve recently tried to make my python more readable using the conceal functionality. So now I went from this to this . Now what really bugs me here is that ƒ, ¶,the ¥ sign, the ℤ and 𝕊 symbols and ...
scientist man's user avatar
4 votes
0 answers
33 views

`local foo=\'` script syntax highlighting error? (slash tick)

Opening vi on a script file containing local varname=\' or local varname=$' seems to mess up the highlighting colors following the tick. Is there a way to avoid this? Here is a simplified example ...
Elliptical view's user avatar
4 votes
1 answer
258 views

Retrieve the match id under the cursor, in all cases

How can I retrieve the syntax id under the cursor, in all cases? Indeed, the synID() function doesn't take into account highlightings due to the :match* commands or the matchadd() function. Example, ...
yolenoyer's user avatar
  • 320
4 votes
0 answers
432 views

Nested syntax folding

Assume I have a syntax as exemplified below and that I want to create a syntax folding definition for the nested begin..end pairs. begin : label a = 0; begin b = 1; end c = 2; begin ...
Vitor's user avatar
  • 1,732
4 votes
0 answers
1k views

Syntax highlight single - quote parameter

Makefiles can have commands such as: BAR = $(subst ', '\'', $(FOO)) Here the first argument to subst is a single single quote resulting in for example: FOO = some ' single ' quotes BAR = $(subst ', ...
Runium's user avatar
  • 1,237
4 votes
0 answers
653 views

Highlight python raw strings as regular expression

I heard someone had set up their editor to highlight python raw strings as regular expressions, e.g. for Django: urls(r'^site1/(\d)*/new$'', ...) Unfortunately my googleing doesn't get me anything. ...
yggdrasil's user avatar
3 votes
0 answers
412 views

How to disable spell check for a single line (with a custom tag)

Sometimes I do not want to add words to a spellfile, but still ignore them this once. This is particularly prevalent when I write markdown. It would be nice if I could tag a line with <!-- nospell -...
Patrick's user avatar
  • 191
3 votes
0 answers
67 views

When editing vim script files (*.vim), line continuations are not highlighted properly

When I edit VIM syntax highlighting definitions or any other VIM script file (*.vim), I lose syntax highlighting on lines that are continued from the previous one. For example, syntax region ...
karlh's user avatar
  • 405
3 votes
0 answers
116 views

Is there an easy way to combine multiple fold methods?

I like folding a lot. I like code syntax based folding, custom marker based folding, folding multi line comments, folding parentheses, folding braces, and probably other things I am forgetting. To ...
Zinklestoff's user avatar
3 votes
1 answer
2k views

Vim to highlight functions and user-defined types

I have two scenarios where I want vim to highlight those items. Currently my fix for these are to add the return types directly into the after/syntax/c.vim file, but this gets incredibly tedious. Here ...
David542's user avatar
  • 2,415
3 votes
0 answers
561 views

Can't use special characters in listchars even if setting scriptencoding to utf-8

Here is my .vimrc file: set encoding=utf-8 scriptencoding utf-8 set list set listchars=tab:→· When I open vim, it will show an error message E474: Invalid argument: listchars=tab:→· My vim is Vi ...
haolee's user avatar
  • 275
3 votes
0 answers
117 views

Syntax highlighting shows a yellow bar on Windows 10

Good afternoon, I just started using the Ubuntu shell from Windows 10, and I copied my Mac .vimrc file. Everything seemed normal until these yellow bars started showing up at the end of some lines. ...
novoalg's user avatar
  • 31
3 votes
1 answer
365 views

Vim syntax for python call and keyword arguments: issues with built-in keyword

I am trying to come up with a Vim syntax for python function call, e.g.: foo(notarg==0, arg2, kwarg='a', kwarg2='b') dict(a=1, b=2, c=3) where we want to highlight (i) function name foo, dict (ii) ...
Jongwook Choi's user avatar
3 votes
0 answers
68 views

Syntax highlighting in consecutive single-line comments

I'd like to have rich syntax highlighting (using, say, markdown syntax) inside (single-line) comments (as is done in Rust). For now, I'm using the following code, which is not satisfactory. syn ...
Rodolphe Lepigre's user avatar
3 votes
0 answers
97 views

Can I change the highlight of specific conceals?

I'm using :syn-cchar to replace certain syntactic elements with Unicode characters (à la vim-haskellConcealPlus). Since I'm replacing several different elements, I'd like to be able to highlight some ...
Kyuuhachi's user avatar
  • 161
3 votes
1 answer
423 views

ruby syntax highlighting lost on long files

With a "long" ruby file (896 lines in my case) the ruby syntax highlighting is lost when I G to the bottom of the file. Once that happens and I go back to the top with gg, the syntax highlighting ...
JESii's user avatar
  • 223
3 votes
0 answers
789 views

Prevent fold background color to override gutter

Here's what my colorscheme looks like: But when there are folds, it looks ugly like this: The fold background overrides the "gutter" color, but I would like the gutter to remain gray. Is there any ...
Jerome Dalbert's user avatar
3 votes
0 answers
193 views

Order of matches in syn-cluster

For regular match groups, the last defined group will be the first to match. When using match groups added to a cluster, I can't determine what the match order is. For example: syn match allgroupcol3 ...
hdrz's user avatar
  • 131
3 votes
0 answers
751 views

How to change the color used to highlight function calls?

I would like to know if it was possible to change the color used to display function name. Let's take the following example (using Python): def function1(arg): function2(arg) # ... ...
user7906's user avatar
2 votes
0 answers
39 views

Syntax match only within a particular region (but also within other nested ones)

Is it possible to get VIM to recognize syntax changes inside a particular region? Specifically, I am trying to get LaTeX3's \ExplSyntaxOn...\ExplSyntaxOff syntax to be highlighted, but only inside a ...
karlh's user avatar
  • 405
2 votes
0 answers
25 views

How to test if a particular FileType has syntax for folds predefined?

I wish to automatically set my foldmethod to manual if syntax fold definitions are not defined for a particular Filetype. However, I am unsure how to check if the fold syntax is defined for the ...
Terry's user avatar
  • 61
2 votes
1 answer
154 views

Vimwiki overriding normal md highlighting

I love the concept of Vimwiki, but have a problem with it overriding the default md syntax highlighting. The default works well, and I use it regularly to edit md documents to be used with pandoc. ...
Megymagy's user avatar
2 votes
0 answers
47 views

Fixing syntax highlighting in Latex documents using cleveref

I use Vim and Latex together. I have recently been fiddling with the cleveref package and it kind of messed up syntax highlighting. For example, before using this package, when I wanted to ...
fresh's user avatar
  • 163
2 votes
1 answer
162 views

How to use different rules for highlighting trailing whitespace inside a gitcommit diff?

In my ~/.vimrc, I have: highlight TrailingWhitespace ctermbg=blue autocmd BufReadPost * syn match TrailingWhitespace /\s\+\%#\@<!$/ This highlights trailing spaces, except when I am still typing ...
Flux's user avatar
  • 1,021
2 votes
0 answers
26 views

custom syntax highlight doesn't match in parentheses

In a custom java syntax file (${HOME}/.vim/syntax/java.vim) I wrote syntax match CommonVar /ret/ highlight CommonVar cterm=bold with the intention display the word ret in bold. I tested it with this ...
quiliup's user avatar
  • 155
2 votes
0 answers
54 views

Concealing \begin and \end lines in latex with MathZone

I'm trying to get the lines that have \begin{equation} and \end{equation} to be concealed. I've tried using call matchadd('Conceal','\\begin{equation\*}', 10,13,{'conceal':' '}) and it works, but it ...
Marco Crivaro Nicolini's user avatar
2 votes
0 answers
801 views

Is there a way to get improved MySQL syntax highlighting over what vim offers out of the box?

Having spent a bit of time sorting out my colorscheme for my php files, I'd now like to "prettify" my sql. (I blame lockdown). My sql is spread liberally through my php files, but I've noticed the ...
Codemonkey's user avatar
2 votes
0 answers
406 views

Javascript syntax-highlight for JsDoc comments

I now use plugin vim-javascript just to have a nice syntax highlight for JsDoc comments in my Javascript files. vim-javascript provides nice colors highlight but it conflict with all parentheses ...
Giorgio Robino's user avatar
2 votes
0 answers
1k views

How to fix this `Omni completion (^O^N^P) Pattern not found` error?

I am trying to set up syntax keyword based omnicompletion in vim. I have defined a few syntax keyword Constants in ~/.config/nvim/syntax/spl.vim They are correctly detected and highlighted. They are ...
itsfarseen's user avatar
2 votes
0 answers
234 views

How to make code-folding more efficient

I have a ruby file while is about 5K+ lines long. My current setup uses the vim-ruby plugin. With this, I enable code folding with let ruby_fold = 1 This opens my ruby files pre-folded. I can open ...
Igbanam's user avatar
  • 121
2 votes
0 answers
176 views

How to set syntax keywords dynamically

I'm trying to highlight the keywords for my c++ project. So what I've done is to create a file here: ~/.vim/after/syntax/cpp.vim and put some custom configuration into it. For example, putting the ...
Yves's user avatar
  • 1,013