Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

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.

64 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
15
votes
0answers
402 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
87 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
220 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
247 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
206 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
1k 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
71 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
54 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
77 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
272 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
478 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
626 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 ', ...
3
votes
0answers
461 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. ...
2
votes
0answers
21 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 ...
2
votes
0answers
27 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 ...
2
votes
0answers
34 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
0answers
52 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
92 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
67 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
301 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
291 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
530 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
50 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
258 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
444 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
112 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
245 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
139 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
308 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
1answer
422 views

Overriding highlighting style for one syntax

My colour scheme (morning) doesn't play nice with the quickfix window: I cannot read the selected item's location, because the foreground and background colours are the same. Because of this I want to ...
2
votes
0answers
140 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
613 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
161 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 ...
1
vote
0answers
17 views

vim highlighting doesn't set the right type

This is what I have in my /usr/share/vim/vim80/filetype.vim (the only mention of messages in the file) : " Messages (logs mostly) au BufNewFile,BufRead */logs/couchdb/{,.log}{,.[0-9]*,-[0-9]*} setf ...
1
vote
0answers
26 views

vim doesn't load syntax for a single file

I was toying around with my .vimrc editing it, and then checking in another file whether my changes worked or not. But now I ended up in a state where opening one file with vim file1.tex (this was ...
1
vote
0answers
31 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 ...
1
vote
0answers
40 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. ...
1
vote
1answer
67 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
51 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
31 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
37 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
24 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
2k 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
103 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
25 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
221 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-...