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.

Filter by
Sorted by
Tagged with
22 votes
1 answer
15k views

How can I add additional syntax highlighting rules in my local vimrc?

I installed gvim on both Fedora and Win7. I found that both vim and gvim on Fedora didn't highlight the function name in c code while gvim on win7 did highlight it. I found that on win7, vim73/...
tamlok's user avatar
  • 831
53 votes
4 answers
23k views

Can Vim interpret terminal color escape codes?

Many CLI programs output nicely-highlighted text. While most of them check if the output is going to a file, some include the terminal escape codes. I like the output with the escape codes, but ...
beatgammit's user avatar
  • 1,243
21 votes
1 answer
1k views

How do I enable language-specific syntax inside a heredoc?

When I edit a PHP file and I define a string in a heredoc, syntax highlighting will be enabled inside the heredoc if it is JavaScript syntax or HTML syntax or SQL syntax. However it will not work for ...
MrSnrub's user avatar
  • 431
19 votes
5 answers
7k views

Vim syntax pattern to highlight python keyword argument

I'm struggling with learning vim regexps (I don't know any other regexp very well either), so the main problem is to define regexp that would match some_function_call(simple_value, keyword=value) ...
user1685095's user avatar
  • 1,141
7 votes
2 answers
198 views

a highlight command resets previously declared highlights

I'm trying to tune the highlighting in my vim and I'm trying to set some syntax groups via the match command and highlight them in my vimrc file, because those groups are generic and do not belong to ...
d.k's user avatar
  • 650
5 votes
1 answer
2k views

How to know which highlighting group is used for the background of a word?

Vim highlights the background of certain words (e.g. when doing spellchecking) in a way that I would like to change (because the background and the word itself are almost of the same color, which ...
Eric O. Lebigot's user avatar
102 votes
4 answers
38k views

List known filetypes

How can I get a list of the names of filetypes that vim currently knows about? I want to be able to do this so that when vim doesn't automatically detect a filetype I can try some of the filetypes ...
Praxeolitic's user avatar
  • 2,458
25 votes
6 answers
6k views

Set cursor colour different when on a highlighted word

With the current colourscheme I have been using, it is hard to find where the cursor is positioned when navigating through search results. The highlighting colour and the cursor colour are blending in ...
ma08's user avatar
  • 353
15 votes
1 answer
12k views

How can I fix "missing" syntax highlighting for Python keywords such as "self"?

I'm trying to fix syntax highlighting for python; my colors are different from those in screenshots of what it "should" look like in different vim color schemes. And you can see the difference in ...
sl8r000's user avatar
  • 153
13 votes
3 answers
6k views

Vim slows down over time with syntax on

Is there anything I can do to keep syntax on when using Vim? As soon as I open anything substantial it becomes nearly impossible to edit after a while. Every keypress causes a delay. If I turn syntax ...
firedev's user avatar
  • 2,382
12 votes
1 answer
856 views

Mixed color syntax in vim

I am often writing documents in knitr using vim, which means that I have markdown code mixed with R code. I would like to have R syntax coloring on R chunks, but markdown or no coloring on all the ...
January's user avatar
  • 263
8 votes
1 answer
6k views

Vim syntax highlighting for custom C types

I want to use syntax highlighting for custom C types. Based on my coding convention, types can occur in the following places: typedef type1 type2; (static | extern | register | volatile)? type ...; ...
R.L's user avatar
  • 81
5 votes
2 answers
4k views

Interactively check given string highlight group

We can get highlight group information by the following command :hi[ghlight] {group-name} But is it possible to get this information by given keyword? Something like this : syn match Integer '\d\+'...
Firmin Martin's user avatar
3 votes
1 answer
734 views

Nested highlighting

In html eruby files, I would like to highlight the <% ... %> text in dark green only when it is inside double quotes. I.e. in in this example: I want it dark green instead of white. I know ...
Jerome Dalbert's user avatar
2 votes
3 answers
1k views

Syntax highlighting with multiple matches with `\zs`

The string that I have is this aaabbbb. aaa must become red, bbbb must become blue. I tried this: " here xB is not matched syntax match xA /^a\+/ syntax match xB /^a\+\zsb\+/ highlight xA ctermfg=...
caveman's user avatar
  • 191
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
19 votes
2 answers
3k views

Disable syntax highlighting depending on file size and type

I often have to edit various XML files with vim, which vary wildly in size - from configuration files containing a few hunded lines to production data files with sizes up to 2GB. Having syntax ...
l4mpi's user avatar
  • 845
17 votes
4 answers
12k 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 ...
Wolfgang Jeltsch's user avatar
16 votes
1 answer
600 views

Treat string literals as a different language

I have a number of JavaScript files where the strings are snippets of HTML to be inserted into the webpage. Vim performs syntax highlighting on the JavaScript, and highlights the quoted strings as ...
KRyan's user avatar
  • 264
15 votes
1 answer
1k views

Can vim syntax regions be made to touch/overlap?

So a while ago I had decided to learn more about how vim's syntax files work, by creating my own. My goal was to create a simple syntax file that would split the file into 3 parts based on delimiters,...
Izkata's user avatar
  • 323
8 votes
1 answer
751 views

Why don't I get syntax highlighting when I open a file in an autocmd?

While trying to devise a solution to How do I make vim look in a set of directories for a file, if it doesn't exist in the current directory?, I have got so far using Python: function LookupFiles ...
muru's user avatar
  • 24.8k
6 votes
1 answer
219 views

Disable spell checking for URLs in BibTeX

I would like to disable spell checking for the URLs in my BibTeX (.bib) files. I was able to disable spell checking for the citation keys (author-year or author+year) as follows: autocmd FileType bib \...
Rudolf Adamkovic's user avatar
6 votes
2 answers
5k views

How to set a colorscheme that still shows spelling errors?

How to set a colorscheme that still shows spelling errors? I am looking for two combined effects that I can acquire separately but not yet together. Set Colorscheme alone: OK. If I want highlights ...
nilon's user avatar
  • 217
5 votes
1 answer
5k views

Custom syntax highlighting: highlight word following keyword

I am currently trying to set a custom syntax highlighting using a mysyntax.vim file. I have several keywords (int, real, real2D, real1D, etc) currently highlighted using syn keyword VariableType real ...
Feffe's user avatar
  • 1,761
5 votes
2 answers
815 views

Vim `cpp` Syntax highlighter prematurely ends macros mid-word

NOTE: This question is a "manual migration" from here: https://superuser.com/q/875751/199803 My Vim syntax highlighter for ft=cpp is prematurely ending some macros mid-line. For example: (The ...
Kyle Strand's user avatar
5 votes
1 answer
2k views

Visual Differences between vim on virtualbox Ubuntu guest (through putty) OR gVim on Windows host

Ok, it's a curiosity more than a real question, I apologize in advance for long post: Usually I code with vim on a ubuntu headless, as a virtualbox guest on my stupid windows 7 host; I access linux ...
Giorgio Robino's user avatar
4 votes
1 answer
1k views

How to identify the highlight groups in use on a particular character? [duplicate]

I'm new to vim and bumped into a problem. Short question -- will vim tell me why it chose to highlight certain text in a certain way? Long question -- I'm using vimdiff to compare two files, and ...
hymie's user avatar
  • 145
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
3 votes
1 answer
911 views

vim 8.0 not honoring custom colors

I updated from 7.4 to 8.0 last night and vim stopped honoring the highlight commands in my .vimrc file. Minimal complete example: with a .vimrc that contains only the following " a comment sy enable ...
Circonflexe's user avatar
40 votes
9 answers
19k views

How do I prevent vim from hiding symbols in markdown and json?

This drives me crazy, I do :set ft=text To see something, otherwise all the links disappear in markdown and quotes in JSON. How do disable this once and for all?
firedev's user avatar
  • 2,382
38 votes
3 answers
19k views

How do I tell vim that some file extensions are synonymous?

I edit C++ code in .cpp files, while template code goes into .tcc files. When I open such a file, no syntax highlighting is available. I tried set syntax=cpp in a a tpp.vim file in ~/.vim/ftplugin/, ...
oarfish's user avatar
  • 1,257
22 votes
3 answers
16k 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 ...
sohnryang's user avatar
  • 495
13 votes
1 answer
4k views

Highlight whole todo comment line

I'm still learning Vim and making small customizing on it. I'm struggling a bit to create a custom style/syntax highlight which would highlight the whole todo line. So in the picture instead of having ...
Tumetsu's user avatar
  • 233
12 votes
4 answers
21k views

How to completely turn off colorscheme?

Original post I've got a colorscheme configured in my .vimrc but sometimes I'd like to turn it off completely which means that I would like Vim to use the default background and foreground colors of ...
Mateusz Piotrowski's user avatar
12 votes
3 answers
2k views

Syntax highlighting is gone after :bufdo :e

I'm using console vim within a tmux window, therefore occasionally vim doesn't recognize that files have been modified (gvim does it on a focus change AFAIK) and in order to avoid getting inconsistent ...
Petr's user avatar
  • 223
10 votes
2 answers
2k views

Exclude start and end match from region

I'm trying to establish syntax coloring for a certain lexical syntax: a "buffer literal". A buffer literal begins with #b' and ends with '. Between the single quotes, there can be undivided pairs of ...
Kaz's user avatar
  • 481
8 votes
2 answers
2k views

Read values from a highlight group

I can read a value from an option like: let b = &background Is there a way to read a value from a highlight group? Something like this pseudo-code: let b = &StatusLine['ctermbg'] ...
ericbn's user avatar
  • 235
8 votes
2 answers
2k views

Can I make Vim's spell check not syntax-aware, and check everything?

The Vim spell checker is code-aware; it uses the syntax file to disable spell checking for the parts where it usually doesn't make any sense. However, on occasion I do want to spell-check this. ...
Martin Tournoij's user avatar
8 votes
2 answers
11k views

How to avoid "Avoid E173 (n more file(s) to edit)?"

So, when I open multiple files, but don't visit the all of them (or the last one), and I try to :quit neovim yells at me that I have to edit those files. No I don't! Stop giving me this error : ) It ...
Costa Michailidis's user avatar
7 votes
4 answers
6k views

Colorizing plain text

I love vim, i use it all the time for write codes, but now I want to write some personal notes. I'm trying vim-pandoc (with vim-pandoc-syntax) and it's nice to have 'rich text' features like titles, ...
Raúl Barriga's user avatar
7 votes
1 answer
917 views

Highlight double space in markdown

When writing markdown, a double space at the end of a line indicates a line break. Currently, neither single trailing whitespaces nor double-whitespaces are being highlighted. Is it possible to have ...
alexytsu's user avatar
  • 816
7 votes
1 answer
2k views

Why doesn't Vim recognize HTML inside PHP?

The HTML that's being returned by this PHP function doesn't have any syntax highlighting. If I delete the ' on line 13 the HTML highlighting works (but the PHP function breaks), with it the HTML ...
alec's user avatar
  • 785
6 votes
2 answers
1k views

Highlighting another syntax in a shell heredoc

I edited my original question and title to broaden its scope to any syntax - with SQL used as just an example. You can adapt the examples and the answer to other languages. By adding suitable ...
stepse's user avatar
  • 201
6 votes
1 answer
2k views

Change default syntax highlighting scheme

I'm unhappy with the default syntax highlighting in vim and would like to change it. I tried to follow the accepted answer on this page, but I think my vim version (7.4) is different. Inside /usr/...
ankush981's user avatar
  • 201
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
6 votes
1 answer
510 views

Highlight heredoc as perl code

I would like to highlight all the HereDocs in a particular perl file as perl code. For example, I'd like to apply the normal perl highlighting to the subroutine in this HereDoc: my $code = <<'...
Mark Grimes's user avatar
6 votes
2 answers
517 views

Syntax file: keywords within context

I have a language which uses statement like WHILE ... DO .. END_WHILE I can do the following in the corresponding synthax file syn keyword LangKeys WHILE DO END_WHILE syn region LangBlock start="...
clem steredenn's user avatar
5 votes
1 answer
3k views

How can I highlight all function names in Python files?

I try to make python.vim color similar to material theme (sublime text 3), see pictures: https://i.stack.imgur.com/Zg5pp.jpg expected is material theme and current is mine. You may noticed that all ...
Tuyen Pham's user avatar
  • 1,306
5 votes
1 answer
2k views

syntax highlight for whole line

I want to color the background of a keyword but also for the whole line where it is found. The file has entries like this: \begin{frame} \frametitle{title} \framesubtitle{subtile} \end{frame} Lines ...
user2567875's user avatar
5 votes
1 answer
468 views

How can I make text formatting ignore concealed characters?

Question Working with text and various markup languages in Vim I have recently experimented with the conceal feature to hide some of the more verbose markup. I switch conceal off when writing and ...
jjaderberg's user avatar
  • 3,469