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.

Filter by
Sorted by
Tagged with
54
votes
4answers
14k 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 ...
29
votes
2answers
7k 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 ...
25
votes
2answers
2k views

Vim's syntax highlighting considers a lambda (->) in Java an error

I am using Vim to program in Java 8, and am having a problem with syntax highlighting. A new feature in Java 8 is lambda support, which resulted in the creation of the arrow operator: ->. Vim ...
21
votes
3answers
9k 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/, ...
19
votes
6answers
4k 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 ...
19
votes
1answer
449 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 ...
17
votes
5answers
5k 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) ...
16
votes
3answers
7k 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 ...
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 ...
16
votes
1answer
327 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 ...
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 /...
14
votes
1answer
13k views

How can I change the colour of the line highlighted with the 'cursorline' option?

I can highlight the current line like this :set cursorline, which underlines the current line. However I would like to highlight the entire line in a lighter color. How can I achieve this look?
13
votes
2answers
843 views

Auto Highlighting identical lines text

I saw a skilled vim ninja do this a while back but I have no idea were to start. A) Is there a way to set up vims background colour so that consecutive lines with identical content get highlighted. ...
13
votes
1answer
917 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,...
12
votes
1answer
636 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 ...
11
votes
2answers
5k 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?
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 ...
11
votes
1answer
7k 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
1answer
623 views

Where do custom highlighting rules belong?

Occasionally I want to override the default syntax highlighting colours and styles with my own preferences. I imagine the most appropriate way to do this would be to create my own colorscheme. ...
10
votes
2answers
347 views

How can I add syntax highlighting to vim as I can do in gedit?

When I write a script in gedit, the commands, comments, variables etc... are given different colors. How do I setup vim to do the same?
10
votes
1answer
1k views

How can I highlight matching “%” names (e.g. if/end, for/end) defined by matchit.vim on selection?

Currently my Vim highlights matching parentheses, brackets, quotes, etc. with Cyan background and white foreground -- the cursor can be moved between these with %. Thanks to my matchit.vim, I can also ...
9
votes
3answers
425 views

How to output highlighted source code into a file to use outside vim

At my workplace, I want to do a presentation of a custom language I've developed for solving some problems we had. For easier development, I created my own vim syntax file for this particular language....
9
votes
2answers
366 views

Is it possible to assign a sign to “Todo” group?

Is it possible to add a sign to be displayed in the signs column whenever the line has a ToDo group (ToDo,FIXME...). Tweaking my colorscheme I changed the highlight of the Todo group, but would like ...
9
votes
1answer
5k 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/...
9
votes
3answers
5k 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 ...
9
votes
1answer
761 views

Vim syntax highlighting of numeric literals with single-quote digit separators

C++14 provided us with the option of using single quotes to separate the digits of large numeric literals. This breaks Vim's syntax highlighting. For example, consider the following C++14 program: #...
8
votes
1answer
276 views

How to escape significant keywords from syntax files?

I came accross this line in a syntax file.. it does not work: syntax keyword Type Transparent I guess this has something to see with the fact that transparent is a significant keyword for Vim. What ...
8
votes
4answers
1k views

SpecialKey foreground color w/ cursorline set

In this Q&A, it's observed that there is a highlight group for CursorLineNr, which applies to the line number for the cursor line when set cursorline is on. I notice that using cursorline also ...
8
votes
2answers
236 views

How can I get correct autocompletion for ambiguous file extensions?

I'm editing Prolog files as part of an exploratory project, and some of the files I'm working with have the extension .pl, which is shared by Perl files. Whenever I do work on a Prolog file named [...
8
votes
2answers
3k views

Markdown: how to syntax-highlight Bold and Italic in different color than normal text?

Text marked as__bold__ or _italic_ appears in the same color as normal text. Headings and code do show up in different colors, so vim correctly recognizes the file as markdown. This is no matter ...
7
votes
2answers
143 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 ...
7
votes
2answers
138 views

Is there a way to restrict search results to differences in a diff?

I want to be able to search only within the DiffText regions of a file that I'm editing. Related question: https://stackoverflow.com/questions/2683521/vim-search-in-c-c-code-lines The accepted ...
7
votes
2answers
8k 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 ...
7
votes
1answer
1k views

Syntax highlight region / keyword overlap

I'm trying to write a syntax file for Linux logrotate scripts. Often they contain inline definitions of scripts to be run before or after the rotate action. An example (the cups-daemon logrotate ...
7
votes
1answer
3k views

Override cursorline background color by syntax highlighting

I've set the background color of the current line to light gray like this: hi CursorLine cterm=NONE ctermbg=253 (Note that my color scheme is black-on-white.) However, this way any background ...
7
votes
1answer
309 views

Does a Vim syntax highlighting file already exist for this log file format, or how can I easily make one?

I wonder if there's already a Vim syntax highlighting in existence that I could use out-of-the-box or modify if it's close to what I want. The log file format I want to highlight stuff in looks like ...
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. ...
7
votes
1answer
868 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 ...
6
votes
4answers
1k views

How to copy text with syntax highlighting?

Want a simple way, like notepad++ plugin: NppExport - Export to RTF, to copy selected text with syntax highlighting. Notepad++, NppExport, Export to RTF example: Select text Copy RTF Paste ...
6
votes
2answers
893 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 ...
6
votes
1answer
644 views

Vim to highlight only a submatch

Folks, I'm writing a syntax highlighting script for vim, but I'm struggling on how to highlight only a submatch of a pattern. For example, suppose that I want to highlight any number within #, like #...
6
votes
1answer
1k 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 ...
6
votes
1answer
388 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
538 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 ...
6
votes
2answers
210 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="...
6
votes
1answer
580 views

Setting syntax in ftplugin

I’m trying to set the syntax of Processing files (*.pde) to java with a ftplugin. .vim/ after/ ftdetect/ pde.vim ftplugin/ processing.vim In after/ftdetect/pde.vim I ...
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
2answers
474 views

How to create syntax folding for pascal

I mostly want it to automatically create folds for between a begin and an end, although if there's anything more advanced that would be welcome too. I've looked in the help for the pascal syntax and ...
5
votes
2answers
610 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 ...