Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

3
votes
1answer
263 views

neovim takes a long time to open files

On profiling, I found that <SNR>101_parse_screen() is taking above 6 seconds. This problem goes away when I comment out the plugin vim-polyglot. This is most evident for vue files. Not sure if ...
2
votes
1answer
204 views

How do I highlight pc-lint comments in C/C++

How do I mimic the behavior of Doxygen comment highlighting for PC-lint comments? Comments are in the following formats: /*lint ... */ //lint ... /* LINTLIBRARY */ /* ARGUSED */ /* VARARGS[N] */ <-...
2
votes
0answers
229 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 ...
1
vote
1answer
420 views

How to reload the current file to change syntax highlighting (ex: adding a shebang)?

I always prefer shebangs over extensions. A lot of times I make a new file without an extension in vim, which gets opened as plain text, since no extension is provided, which is completely normal. ...
1
vote
1answer
402 views

Highlight all imported modules in python

For example import numpy as np import matplotlib.pyplot as plt x = np.array([-1, 0, 1]) y = np.abs(x) plt.plot(x, y) plt.show() Is there a way to highlight all the occurrences of np and plt?
4
votes
1answer
334 views

Can I show a color from its hex value in *any* file?

We have vim-css-color to display colors in .css files. Currently I'm editing my i3wm config to match colors to a new terminal theme and it would be quite handy to be able to actually see colors I'm ...
2
votes
1answer
115 views

How to share syntax highlights files for a “new” language?

In past I asked the question about how to create syntax specifications for ChatScript, a new programming language unforeseen in standard programming languages vim set (see: Vim syntax highlighting for ...
2
votes
1answer
51 views

Where is `javaParen` defined?

I want to write my own java syntax file for more customization, But can't find the definition of javaParen, it certainly isn't defined in default java.vim file. I actually want to highlight all the ...
1
vote
1answer
507 views

Adding multiple syntax group to a syntax region

I’m writing a syntax file for Bats. I started my syntax file by loading the bash syntax: let g:is_bash=1 runtime! syntax/sh.vim unlet b:current_syntax I then defined the Bats custom keywords: ...
0
votes
1answer
117 views

Vim with syntax highlighting has slow searching in XML

My experience is that Vim is slow when searching in large XML files with syntax highlighting turned on. I find it to be very dissatisfactory. I have read about the issue elsewhere but I have not been ...
5
votes
1answer
237 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 ...
0
votes
0answers
9 views

“set background=dark” masking highlight command [duplicate]

If my .vimrc file has this: set background=dark highlight Comment term=bold ctermfg=white ...comments are white as expected. But if I reverse the order of the statements: highlight Comment term=...
0
votes
1answer
364 views

Folding doesn't work for C/C++

I've been having a ridiculously hard time getting C/C++ code folding to work with set foldmethod=syntax. To debug my issue I've stripped down my vimrc to only this: set foldmethod=syntax syntax on ...
4
votes
1answer
434 views

What does the command `:syntax reset` do?

from the help: :h syntax-reset If you have changed the colors and messed them up, use this command to get the defaults back: > :syntax reset It is a bit of a wrong name, since it does ...
3
votes
1answer
413 views

Why does modifying the `Normal` highlight group affect syntax not belonging to the highlight group?

Im running terminal vim, and when a syntax highlighted file is loaded and I have a colorscheme active and I run this command :hi Normal ctermbg=2 ctermfg=0 ALL text in the window changes, not just ...
0
votes
1answer
71 views

Finding a match immediately after another match [duplicate]

I'm writing a syntax highlighter for my test script output. I'm having problems figuring out how to find a match immediately after another match. In the screenshot, notice the $VAR1... is not ...
3
votes
2answers
763 views

Reloading syntax file without restarting vim

I've tried every tip I can find on this and none of them work. I've cleared my .vimrc file. I have a syntax script in ./vim/syntax/test.vim. It consists of nothing but this: highlight clear syn ...
0
votes
0answers
37 views

Turning on syntax highlighting for test script output to new buffer

I'm using a plugin, bexec, to execute a test script. The plugin opens up a new buffer to the right of my code and it displays the output of the test script: I would like to have syntax highlighting ...
0
votes
1answer
300 views

How do I add syntax keywords globally for any filetype?

I have some keywords other than TODO used in comments that are common to all languages, things like 'NOTE'. I want to label these words under Todo syntax class, so that they have the same colour with ...
2
votes
1answer
279 views

Syntax Highlight line above matched pattern

I am looking for a way to highlight text on the line above a matched pattern. For example, my text may appear like this: Some text --------- What I want is to match on the underline dashes and then ...
3
votes
1answer
98 views

Shortcut to remove orphaned parenthesis

While writing code it often happens that adding one parenthesis leaves another one orphaned somewhere. Many syntax color scheme color the parenthesis differently to signal it. For example, while ...
1
vote
2answers
952 views

Why isn't vim applying syntax highlighting to this code?

If I open a random file (in this case, say .zshrc) in a blank vim with no rc file , but with vi compatibility forcing off vim -N -u NORC ~/.zshrc As expected vim will launch and display .zshrc ...
1
vote
0answers
61 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
417 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
107 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, ...
5
votes
1answer
157 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 ...
2
votes
2answers
2k views

Syntax highlighting for “C like” files [duplicate]

I have a number of files with a syntax almost identical to C, though the files have suffixes such as .t, .sc I would like to have the same syntax highlighting that I have for standard C files ending ...
3
votes
0answers
228 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 ...
2
votes
1answer
298 views

Vim highlights valid shell parameter expansion syntax as an error

#!/bin/bash echo ${2:-"-l -p"} Having some bash parameter-substitution fun and (Neo) Vim complains about it, while the code is perfectly fine. I know I can suppress errors totally by doing sort of ...
1
vote
1answer
79 views

Syntax highlighting only matches strings if the character before the opening quotation mark is a letter

I'm writing a syntax file. To highlight strings, I'm defining a region just like it says in the help file: syn region m2String start=/"/ skip=/\\"/ end=/"/ and later I have: let b:current_syntax = "...
0
votes
1answer
211 views

How can I highlight WinAPI functions in C++?

How can I add syntax highlight for windows.h C/C++ apis and types? All I've found is a tiny winapi syntax file here.
4
votes
1answer
73 views

Extending Haskell syntax highlighting to allow for inline C snippets

There is a Haskell program called inline-C which allows C code snippets to placed inline Haskell code, as follows: main :: IO () main = do x <- [C.block| int { // Read and sum 5 integers ...
15
votes
3answers
5k views

No syntax highlighting in tmux

I installed tmux in iTerm 2.(Build 3.0.13) When I execute vim in tmux, syntax highlighting looks like this. But outside tmux, syntax highlighting looks fine. My $TERM inside and outside tmux is ...
7
votes
1answer
785 views

How can I change the highlighting of python class name?

How can I define a syntax to highlight the python class name MyClass in vim? class MyClass(object): ...... Vim has already highlighted the class name. However, it seemingly highlights it with ...
1
vote
1answer
342 views

How to change vimscript syntax highlighting?

I like the syntax rules and don't need to change them, but what bugs me is that for some reason the author decided to highlight keywords with Structure group and function names with Comment (or ...
1
vote
1answer
500 views

Fix syntax highlighting in LaTeX

I'm using vim 8.0.94. In a TeX file (specifically LaTeX), the three occurrences of \(\) in \(\) {\(\)} {\(\)} should be highlighted in the same way, but they are not. Curiously, in the second, but ...
1
vote
0answers
196 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 ...
1
vote
1answer
1k views

Change spellcheck language via syntax

I have book length prose content in Markdown files that is mostly in Turkish. I've done a lot of work to get Turkish spell checking working decently in vim, so :set spelllang=tr spell works well ...
5
votes
3answers
926 views

Only highlight comments

Does anyone know a way to highlight only comments in vim? Requirements: For any colour scheme. Without having to clear and re-add only the comment syntax group in each language's ftplugin. I ...
1
vote
1answer
166 views

Mixing C-preprocessor and scripting language with highlighting?

We are using a proprietary tool which uses Tcl and the C preprocessor to create input files. Is there any way to get the Tcl syntax highlighting to also recognize the #if, #else, #endif macro ...
2
votes
2answers
157 views

How do I make regexes mutually contain each other?

I've written regexes for markdown for emphasis and bold as follows: syntax match PandocEmphasisMarker "\v(^|\s+)\zs_[^\n\t_ ]+([^_\n]|(\S_\S)|(\s_\S)|(\s+_\s+))+[^\n\t_ ]+_\ze($|\s+)" contains=...
4
votes
1answer
1k views

VIM syntax file, how to match capturing groups?

Lets say I have a line like the following in a vim syntax file: syntax match Emphasis "\v\s+_\zs[^_\n]+\ze_\s+" In this line I'd like to create multiple capture groups: the first underscore as "...
4
votes
0answers
805 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 ...
1
vote
1answer
131 views

Enable templating language (e.g., Liquid) syntax highlighting but keep native (html/css) commenting?

I just started working with Jekyll, which uses Liquid. As a templating language, Liquid is embedded into files of other types (e.g., HTML, CSS, or Markdown). Vim handles this sort of dual syntax ...
1
vote
1answer
58 views

Get all syntax elements with some group name from buffer

In my syntax file I have something like syn match cleanReal "[+-~]\?\<\d\+\.\d+\(E[+-~]\?\d+\)\?" display hi def link cleanReal Float Is there a way to get all strings that are matched as ...
9
votes
3answers
4k views

How can I make highlighting commands in .vimrc take effect immediately with Vim 7.4?

I have several highlight commands in my .vimrc file. In Vim 7.3, these took effect immediately after Vim had started. After updating to Vim 7.4, this is not the case anymore. Vim uses its default ...
2
votes
1answer
82 views

Modify sh.vim to accept (@)_ as part of a variable name for Bash highlighting

I have Bash file in which I have constructs that include (@)_ as part of the variable name. For example: (@)_VariableName ${(@)_VariableName[@]} ${#(@)_VariableName[@]} ${!(@)_VariableName[@]} The ...
0
votes
1answer
64 views

vim syntax file: composite keywords

What if I define keywords as combination of two list of strings? E.g. List1: ['B', 'G96', 'TPSS', 'RevTPSS', 'BRx', PBE', 'PBEh', 'wPBEh'] List2: ['VWN', 'P86', 'PW91', 'TPSS'] and a keyword is ...
0
votes
1answer
124 views

Use .vim syntax file in language REPL

Lets say I have a REPL ./repl, which reads a line from the user, evaluates it, prints it and then repeats. I have a .vim file that does syntax highlighting for this language in my .vim/syntax ...
6
votes
0answers
83 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, ...