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.

56 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
15
votes
0answers
345 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 /...
6
votes
0answers
86 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, ...
6
votes
0answers
214 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 ...
5
votes
1answer
239 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 ...
5
votes
1answer
180 views

How to make a syntax region stop on empty lines?

I would like to adapt this syntax file so that the formatting in VIM matches more closely what this online Markdown editor (GitLab-flavor) displays (the output on the right is relevant, this is how I ...
5
votes
0answers
935 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 ...
3
votes
0answers
53 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 ...
3
votes
0answers
52 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*([-^+|^\/%&...
3
votes
0answers
73 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 ...
3
votes
0answers
254 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 ...
3
votes
0answers
460 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) # ... ...
3
votes
0answers
590 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 ', ...
2
votes
0answers
18 views

Different syntax highlighting in the same file for different languages

Is there a way to use more than one syntax highlighting schemes in one file? Specifically, I'm interested in having part of a LaTeX code highlighted according to my python syntax highlighting rules:...
2
votes
0answers
28 views

head isn't included in syntax/sh.vim

head is a common Unix/Linux executable, but it's not listed in the shell syntax highlighting configuration. In contrast, many common executables are. Specifically, its counterpart, tail, is listed. ...
2
votes
1answer
69 views

How to stylize text between backticks ( ` ) to match text style between single/double quotes ( ' | " )?

In my vim, I'm using gruvbox. Syntax colorization is great for everything except text written between `backticks`. You'll note once backticks are used, all subsequent lines of text are green. I would ...
2
votes
0answers
46 views

Highlight arbitrary rectangular regions

Is it possible to highlight specific and arbitrary rectangles in a buffer? I want to implement a code scope highlight that groups code into a hierarchy of boxes. here is my mockup that I made: ...
2
votes
0answers
82 views

How can I change Javascript syntax to higlight objects?

I am trying to emulate the Atom JavaScript syntax highlighting in vim, but there are a few things missing. Namely, I'd like to highlight objects and their chains in red. It'd be dandy if I could ...
2
votes
0answers
64 views

vim cpp syntax contained region

I define four key words and two regions in vim scripts syn keyword KeywordA A nextgroup=rangeA skipwhite skipnl skipempty syn keyword KeywordB B contained containedin=rangeA nextgroup=rangeB ...
2
votes
0answers
295 views

vim in tmux lose highlighting

I'm using vim 8.0 and tmux 2.5 on ubuntu. And I have set the TERM environment export TERM=screen-256color and run as tmux -2. Normally, nothing goes wrong. It's like the following picture: But ...
2
votes
0answers
39 views

Define region in region with same end match

Let's see an example: block property Property1 key: value end property Property2 key: value end end I would like to let property/end pair highlight only in block/end ...
2
votes
1answer
277 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 ...
2
votes
0answers
489 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 ...
2
votes
0answers
50 views

Syntax highlighting depending on whether whole line is commented

Is it possible to have vim highlight folds differently depending on whether every line in a fold is only comments or whitespace? In that case, how?
2
votes
0answers
46 views

LaTeX tabu package breaks Vim spell and syntax highlighting

The first line of this section of LaTeX code breaks syntax highlighting and spell check whenever I scroll to the area of the document that contains it: \begin{tabu} {*3{X[l$]}} col1 & col2 ...
2
votes
0answers
236 views

syntax highlight function arguments

Trying to create a simple syntax highlighting for a special file type we use. within this file there are simple functions defined which I match using keywords: syn keyword Funcs foo bar baz hi def ...
2
votes
0answers
426 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 ...
2
votes
0answers
108 views

Retrieve the syntax 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, ...
2
votes
0answers
216 views

Custom highlights not working in visual splits

I'm a tabs kind of guy, so I highlight leading and trailing white spaces with the following commands in my .vimrc: highlight whiteSpace_trailing ctermbg=red guibg=red highlight whiteSpace_leading ...
2
votes
0answers
136 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 ...
2
votes
0answers
306 views

Changing background color of cursor during selection

Coming from Sublime, I find the following behaviour frustrating. When I select some text, the first (or last depending upon which way you select) character flashes between the text color and your ...
2
votes
0answers
138 views

Search within syntax group?

Is there a way to take advantage of syntax highlighting for searches? For example, can a search be limited to comments or non-comments, if they are correctly marked by syntax highlighting?
2
votes
0answers
551 views

Turn off markdown highlighting for underscores in inline code?

Markdown highlighting is great (when it works), but I've seen a problem on two different boxes with underscores in inline code and I'm wondering if there's an easy solution. When I put, for instance, ...
2
votes
0answers
159 views

How to match patern inside a syntax region start pattern?

Python group regexp has this syntax (?P<idGroup> ... ), where: (?P<idGroup> is the beginning of a region. ... is the content of the region. ) is the end of region. I highlight start ...
2
votes
0answers
433 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. ...
1
vote
1answer
57 views

How to set LaTeX syntax to “ConTeXt” in vimrc

TL;DR: How do I permanently and persistently :set syntax=context for *.tex files? I've been using vim for a LaTeX project, with monokai-tasty as the colour scheme. The default syntax highlighting ...
1
vote
0answers
41 views

Ignore acronyms as spelling errors in TeX files

My LaTeX files contain lots of acronyms and they are often highlighted as spelling errors. I tried to ignore acronyms by adding syn match AcronymNoSpell '\<\(\u\|\d\)\{3,}s\?\>' contains=@...
1
vote
0answers
28 views

custom syntax hilighting lost on single LaTeX file

I use vimtex plugin for writing tex documents in vim8. I added custom hilight for sections in my .vimrc like so: autocmd FileType tex :syntax match texSectioning "\\section.*" The texSectioning is ...
1
vote
0answers
35 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 ...
1
vote
0answers
23 views

Syntax - Match word based on a previous match

I want to highlight all words that have been matched in another syntax region. Using something similar to regex capture groups, for example given a file: {highlightme} asda asasd asd asd as ...
1
vote
0answers
1k views

E518: Unknown option: termguicolors

This thing is driving me nuts I'm trying to setup vim on my co-workers computer, and this is my .vimrc file everytime I run vim I get this error Error detected while processing /Users/toters/.vimrc:...
1
vote
0answers
94 views

Disable vimdiff syntax highlighting

I have syntax off at the end of my nvim.init file, but no matter how hard I try there is always diffsplit coloring. I would like to disable it because I guess (Neo)vim is very slow with syntax ...
1
vote
0answers
20 views

Determining syntax group type from output of 'syn list' (doesn't appear to work for regions)

Why does the output of syn list not include region in the syntax group definition line, like it does for 'match' type groups? What is the meaning of the xxx in that line? I've got a vim 8.0 function ...
1
vote
0answers
50 views

Match through nested function

I have this sample: I expect arg3 to be colored green as arg1, arg2 and FunCall with my current setting: syn match pyFun "xxxx" contains=xxx syn region pyFunCall start="(" end=")" contained contains=...
1
vote
0answers
34 views

How to access syntax elements

I try to inline one syntax in another syntax (to be explicit: CSS in JS template strings). I'd like to build on top of the existing CSS definitions and not create new ones. Question: Is it possible ...
1
vote
0answers
206 views

Improperly highlighted when used with cursorcolumn

With this minimal .vimrc I get a highlight conflict in several situations. set nocompatible set runtimepath +=~/.vim/bundle/Vundle.vim filetype off call vundle#begin() Plugin 'itchyny/vim-...
1
vote
0answers
63 views

vim-latexsuite syntax highlight in macro parameter

I'm using vim with vim-latex to edit my LaTeX-files. I noticed that the \begin{env} and \end{env} are not colorized when they are in a macro parameter (the \vary command and question environment are ...
1
vote
0answers
100 views

syntax highlighting for indentation sensitive multiline comment

I want to create syntax highlighting for indentation sensitive language that I'm designing, my question is how to highlight multiline comment that begins with #! something like this #! xxxxxxxxxxx ...
0
votes
0answers
22 views

Remove costum commands from vim-spell

I recently tryed following the answer to this question: vim-spell: exclude custom LaTeX commands. To remove spelling from the inside of certain commands, I ended up adding the following to after/...
0
votes
0answers
27 views

Use combining characters in concealment character

Are combining characters allowed in a concealment character? The following does not seem to work: syntax match underdot "a\." conceal cchar=ạ The underdot is U+0323. This syntax conceals a. simply ...
0
votes
0answers
33 views

highlight link with condition file does not exist

For a wiki syntax plugin, i'd like to have two highlighting colors for links. Links already having a destination file should be green and links with no destination yet should be red. [[This file ...