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
1
vote
2answers
2k 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 ...
3
votes
1answer
137 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
0answers
65 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 ...
2
votes
0answers
117 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, ...
3
votes
0answers
469 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
2answers
163 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=...
1
vote
1answer
118 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 = "...
5
votes
3answers
1k 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 ...
2
votes
2answers
5k 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 ...
12
votes
1answer
825 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. ...
4
votes
0answers
310 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 ...
0
votes
1answer
265 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
89 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 ...
7
votes
1answer
1k 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
500 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 ...
12
votes
1answer
8k 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 ...
1
vote
1answer
694 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 ...
2
votes
0answers
282 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 ...
4
votes
1answer
590 views

Syntax highlighting with nested braces and forbidden keywords

I would like to write a syntax highlighter for a language like this one: block1 { keyword1 value; keyword2 value; sub_block1 { keyword3 value; } } block2 { keyword1 value; } A ...
2
votes
1answer
2k 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
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 ...
1
vote
1answer
202 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 ...
5
votes
1answer
2k 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 "...
1
vote
1answer
178 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
70 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 ...
2
votes
1answer
92 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
69 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
153 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 ...
4
votes
1answer
446 views

Syntax highlighting for custom LaTeX commands

I have a few custom LaTeX commands like this one, for instance: \newcommand{\oeuvre}[1]{\textit{#1}} I use this for titles of books and other works. Sometimes I want them to be italicized, sometimes ...
2
votes
1answer
65 views

batch create html colored versions of a list of files reflecting syntax highlighting

I would like to be able to easily create html-colored versions of a list of files (ex: "all the files in this directory", or "this list of files") I know that I can do this manually, one by one, by: ...
5
votes
2answers
2k 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 ...
0
votes
1answer
55 views

Allow comment highlighting inside biblatex entries

The default syntax highlighting for bib files doesn't highlight comments inside entries, like this: @book{test, % title = {This isn't highlighted as a comment}, } That's because bibtex doesn't ...
1
vote
1answer
92 views

Git submodules for syntax files

I keep my VIM folder under git version control. I use git submodules and Pathogen to keep my VIM plugins updated. The folder structure is .vim/bundle/$PLUGIN Is it possible to use git submodules for ...
9
votes
1answer
872 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: #...
1
vote
0answers
143 views

syntax highlighting for indentation sensitive multiline comment

I want to create syntax highlighting for indentation sensitive language that I'm designing, my question is how to highlight multiline comment that begins with #! something like this #! xxxxxxxxxxx ...
2
votes
1answer
69 views

How to do restrict keyword inside special lines?

I am trying to write a VIM highlight file for Gaussian 09 inputs. One example of "control" line is shown below: # P TPSSTPSS 6-31G* DENSITYFIT OPT(VERYTIGHT) INT(ULTRAFINE) FREQ(NORAMAN) TITLE ...
7
votes
1answer
3k 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 ...; ...
3
votes
1answer
727 views

How to highlight windows end of line characters aka ^M, \r\n?

I would like to set a different highlighting for windows EOL characters. I have tried several approaches and some of them worked when I did : so $MYVIMRC, which is pretty strange, because after I ...
1
vote
1answer
44 views

How to avoid repeating pattern strings in syntax files?

In my syntax description file I'm trying to define something like the following syn match arbSAMPLEop "\<\(TEX\|TEX_SAT\|TXP\|TXP_SAT\|TXB\|TXB_SAT\)\>" syn match arbTexTarget "\<\(1D\|...
2
votes
1answer
71 views

syntax: match all lines with a given pattern that follow a line with a different pattern

I'm writing a Syntax file for Robot Framework. I want to create a color scheme for the [Documentation] tag, such that the text following the tag, and all subsequent lines beginning with ... until the ...
4
votes
1answer
221 views

New lines are not continuing block comments, only in php

Say I type /** and hit return. In a .cpp file, or a .js file, the cursor would continue adding *s for me. /** * But in a .php file, the cursor just moves to the next line. It's very annoying ...
1
vote
2answers
692 views

Customize syntax highlighting in netrw

Right now I am working on a latex project. When I open a netrw/vinegar window, I get following coloring: Apparently, certain filetypes are grayed out and other are not. I like the idea to emphasize ...
3
votes
0answers
153 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
2answers
1k views

How do I get Vim to correctly highlight Math mode in LaTeX command options?

I adopted the bracket notation, e.g., x[i], for the discrete signal x where i is the time index. The problem occurs in a pgfplots figure but I figured, the syntax highlighting behavior is due to being ...
2
votes
0answers
323 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 ...
7
votes
2answers
142 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 ...
3
votes
0answers
564 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
1answer
1k 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 ...
4
votes
1answer
372 views

How to check whether the cursor is at the boundary of a syntax item for indentexpr?

I'm writing my own indentexpr to indent my code, the indentexpr is run in a sandbox, so one important point is that I cannot change the text content. I have set up the syntax highlighting for quoted ...
2
votes
0answers
143 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?

1
5 6
7
8 9