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.

8
votes
1answer
4k 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/...
19
votes
1answer
416 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 ...
16
votes
4answers
4k 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) ...
7
votes
2answers
127 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 ...
11
votes
1answer
6k 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 ...
11
votes
3answers
4k 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 ...
3
votes
1answer
326 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 ...
46
votes
3answers
11k 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 ...
28
votes
1answer
5k 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 ...
13
votes
1answer
853 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,...
3
votes
1answer
375 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 ...
16
votes
1answer
293 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 ...
16
votes
2answers
2k 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 ...
13
votes
0answers
297 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
1answer
492 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 ...
5
votes
1answer
1k 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 ...
5
votes
2answers
579 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 ...
19
votes
5answers
3k 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 ...
20
votes
3answers
7k 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/, ...
5
votes
1answer
289 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 ...
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 ...
7
votes
2answers
1k 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. ...
6
votes
2answers
7k 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 ...
6
votes
2answers
196 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="...
5
votes
1answer
510 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 ...
5
votes
1answer
2k 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://imgur.com/a/wOgH7 expected is material theme and current is mine. You may noticed that all method, ...
5
votes
1answer
653 views

Improve performance of syntax highlighting in Vim

I have some C++ sources files which are in a few mega-bytes (a few tens thousands lines) to view and edit. The performance looks really bad in Vim. Refersh (<C-l>) or input single char in insert ...
4
votes
1answer
2k views

Tmux messing with Vim highlighting [duplicate]

When I load up vim inside tmux there is a background color behind all text as so: If I load it up not in tmux I get the following: I want it to be like image 2, I can not understand why tmux is ...
4
votes
1answer
1k views

Syntax highlighting for markdown can't be set manually

If the file is named *.markdown then the highlighting works correctly. If it is named *.md then it doesn't work. Even if I type :set syntax=markdown, the highlighting doesn't turn on. With other ...
4
votes
2answers
331 views

Vim syntax highlighting for ChatScript language?

I'm looking for a ChatScript language Syntax highlighting, of course for the Vim editor. ChatScript is a great (underrated) open-source language to build chatbots dialog flows scripts, made by Bruce ...
1
vote
2answers
604 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'] ...
12
votes
1answer
600 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 ...
6
votes
1answer
364 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 = <<'...
6
votes
1answer
938 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 ...
5
votes
0answers
865 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 ...
5
votes
1answer
1k 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/...
4
votes
1answer
748 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 ...
4
votes
2answers
1k views

Adding conceal to already existing syntax highlighting?

I'm using Vim with the Vaxe plugin for syntax highlighting, the plugin's highlighting file is here for reference. I'm trying to add some conceals to tidy up the code visually, but I can't seem to get ...
2
votes
1answer
68 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 ...
2
votes
1answer
603 views

Syntax highlight multiple matches in the same line

I would like to know how to highlight multiple tokens in the same line. For example, if I want to highlight the value of 'a', I can write something like this: syn match num 'a=\zs\d\+\ze,b=\d\+.*' ...
2
votes
1answer
905 views

How can I fix the default bash syntax highlighter?

I'm having some issue with the default "Dr. Chip" sh.vim highlighter. Specifically, it's failing to recognise the comment character # after a touch command. e.g. touch foo # it's here It doesn't see ...
2
votes
0answers
135 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
1answer
613 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 ...
1
vote
2answers
302 views

Highlight exported Go functions

Golang uses naming convention to separate functions visibility: exported (public) starts with a capital letter, non-exported (private) with a lower letter. I would like to highlight exported functions,...
1
vote
2answers
447 views

Syntax highlighting of underscores in LaTeX, even though they only appear in filenames

I'm using nvim and LaTeX together, and for the most part it's been great. However, nvim appears to be incorrectly highlighting underscores that appear in filenames I include as part of the subfiles ...