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
4
votes
1answer
1k views

Code syntax checking using highlighting

Some languages have flow control or loop structures that require a few words, for example, shell has if [...] then ... fi Is it possible to use the syntax highlighting features of vim to indicate ...
4
votes
2answers
120 views

Syntax highlighting for StackExchange markdown

I often "pre-compose" and save my longer questions for StackExchange usign Vim / GVim. Does a syntax highlighting file for the StackExchange markdown already exist? If yes, where can I obtain it? ...
4
votes
1answer
576 views

Highlighting Date in Vim

I have a file that has dates in this format: Fri Jun 05, 2015. It's essentially a diary. I have created the syntax keywords Day, Month, dateNum, and Year for the various components of the date but I ...
4
votes
1answer
76 views

LaTeX dollar signs confuse syntax highlighting

I am editing LaTeX code such as: \documentclass{article} \usepackage{booktabs,tabularx} \begin{document} Blah blah Blah blah \begin{table}\centering \begin{tabular}{>{$}l<{$}p{4in}} %...
4
votes
1answer
740 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 ...
4
votes
2answers
2k 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 ...
4
votes
1answer
95 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 ...
4
votes
1answer
565 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 ...
4
votes
1answer
400 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 ...
4
votes
2answers
161 views

Is it possible to override the filetype of a text file based on the first line?

I have some specifically formatted text files that I'd like to detect when I start vim. When I load these files now, the filetype is automatically set to text. I only want to override that if the ...
4
votes
1answer
477 views

Syntax highlighting of key = value pairs

I "inherited" a custom syntax script and I want to update it since it's a little out of date. The text file for which the syntax highlighting is written contains several blocks like this: {Group1 ...
4
votes
1answer
320 views

How to conceal Markdown syntax per-word, rather than per-paragraph?

I want to use Vim to write markdown in a sort-of-WYSIWYG manner (for use with an audience). For example, typing **Bold** should display Bold in bold font, with the asterisks automatically hidden as ...
4
votes
1answer
739 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 ...
4
votes
1answer
437 views

Add keyword to existing syntax file without changing the original syntax file

How should I ideally modify an already existing syntax file without touching the file itself (since it's normally not world writeable)? I want to add the keyword \autoref to TeX's syntax highlighting,...
4
votes
1answer
223 views

Prevent C incomplete string matching from highlighting the rest of the code with the string color?

Not sure I said it right, it's kinda hard to explain with words, so: I don't know if syntax highlighting trying to be helpful here or what, it's definitely annoying and distracting. I simply don't ...
4
votes
1answer
100 views

Custom syntax file for FIX data doesn't work

I tried to create a custom syntax file to read FIX messages. Note: I am certain my custom files are being loaded by Vim. The file format is sequences of NUMBER=VALUE pairs separated by the ...
4
votes
1answer
155 views

How to get highlighting group set by spell check

How do I get the highlighting group of a text when the group is defined by the command :spell? For example when a word is misspelled I want to get the highlighting group SpellBad. We have a question ...
4
votes
1answer
3k views

Vim black text on black background in command line in Windows 10 while editing git commit message

I am using git 2.7.0.windows.1 in Windows 10, with core.editor set to vim. Vim was downloaded from vim.org latest version binary: VIM - Vi IMproved 7.4.1023 (2013 Aug 10, compiled Jan 2 2016 14:24:...
4
votes
1answer
866 views

Turn off markdown highlighting for underscores in inline code?

Markdown highlighting is great (when it works), but I've seen a problem on two different boxes with underscores in inline code and I'm wondering if there's an easy solution. When I put, for instance, ...
4
votes
1answer
2k 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
0answers
77 views

Is it possible to use syn match dynamically

I know that syn match can work with the regular expression to do some custom highlight settings. I'm thinking if it can work dynamically. For example, I'm doing a c++ project and I want to highlight ...
4
votes
0answers
60 views

How can I make syntax highlighting files more readable and maintainable?

Vim uses regular expressions for syntax highlighting. Often maintaining these can become rather unwieldy. For example: syn match goVarAssign /\v[_.[:alnum:]]+(,\s*[_.[:alnum:]]+)*\ze(\s*([-^+|^\/%&...
4
votes
0answers
352 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 ...
3
votes
3answers
739 views

Is there a way to dump syntax highlighting to a .vim file?

If I set syntax highlighting rules manually (not in a file), is there a way to save them out to a file? Specifically, the goal is to source this file to restore the syntax highlighting rules later on.
3
votes
2answers
3k 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 ...
3
votes
1answer
1k 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. ...
3
votes
2answers
1k 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 ...
3
votes
1answer
528 views

What options make Vim aware that the file editing is for vim settings?

I am editing a non-standard file of Vim settings and the file has no syntax highlighting because Vim is not aware that the file contains settngs for itself. eg - These lines are not highlighted by ...
3
votes
1answer
2k views

How to change Vim's :hardcopy printfont?

I would like to be able to print in other than Courier font using the :ha command. Investigating more closely, I found that it is documented that the Courier font is always used: - 'printfont' - The ...
3
votes
2answers
845 views

Poor syntax highlighting in vimwiki (command prompt)

Is there any way to change the syntax highlighting in vimwiki in windows. I could not properly see the line enclosed between [[some word]]. The same works well in Linux.
3
votes
2answers
931 views

How can I override a syntax keyword match?

I would like the html tag attribute id to be highlighted differently from the rest of the tag attributes. Like the Atom editor: Given this line from the html5.vim plugin syn keyword htmlArg ...
3
votes
1answer
331 views

Efficient Syntax Highlighting

I am using VIM as a note taking application and have created syntax highlighting to assist with readability. See below or the repo for all the files. syntax match Timestamp /^\d\d:\d\d \d\d[/]\d\d[/]...
3
votes
1answer
1k views

Is it possible to make text blink inside vim?

There are ANSI escape codes (namely 5 and 6) that make subsequent text blink and my terminal (rxvt-unicode-256color) does support this. Is there a way to allow this to happen using hi? EDIT: From ...
3
votes
1answer
675 views

Aditional SQLite syntax highlighting in VIM

Currently I'm editing some SQLite scripts with my filetype set to ft=sql and some types aren't being highlighted and : REAL TEXT There is some configuration that I'm missing ? I've searched for a ...
3
votes
2answers
135 views

What exactly do patch 8.2.1693 and patch 8.2.1703 do to syntax highlighting?

It is fairly well known that syntax highlighting in vim breaks when one changes colorschemes frequently. This is due to peculiarities of hi def/hi clear. Recently, the following changes were made: ...
3
votes
1answer
147 views

Syntax region only if at top of file

I have a syntax I'm trying do make. It's yaml embedded in markdown for use with Hugo. The yaml region is enclosed by --- and this must be at the top of the file. --- [yaml front matter stuff] . . . --...
3
votes
1answer
752 views

Syntax-highlighting is getting screwed when loading long markdown files on Windows

Note: this may be a Windows-only problem. The symptom has been reproduced on multiple Windows 10 machines. I find my syntax-highlighting for Markdown files (ending in .md) will fail to rander when ...
3
votes
1answer
762 views

How to highlight unused Python imports in VIM

I want to highlight unused Python imports as Python syntax errors. For example, I sometimes forget to remove some packages used for debugging such as time, ipdb. It would be great to see warnings or ...
3
votes
1answer
171 views

Avoid highlighting defined by 'matchadd' in comments

I want the piece of text std::string to be highlighted in vim according to the style defined in 'Type'. I can do that with :call matchadd('Type','std::string') It works. However, std::string is also ...
3
votes
1answer
589 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 ...
3
votes
1answer
219 views

match special types in C

vim has some great highlighting for built-in keywords, functions and types, but when working on some non-built-in projects, this seems not enough. For instance, the keyword before a variable is mostly ...
3
votes
1answer
79 views

Syntax highlight groups of digits in large number

I often view logs in vim, and the log contains large numbers eg 3244522321. It's very difficult to tell if this is 324M, 32M, or 3.2M. Is there a way to set up something (syntax highlight?) that will ...
3
votes
1answer
569 views

Conceal markdown links and extensions

I wish to fully conceal markdown links, even if they have extensions. For example: [Anchor text](http://whatever...) [Anchor text](http://whatever...){:rel="nofollow noopener noreferrer" ...
3
votes
1answer
388 views

Highlight syntax in start and end delimiters of region

I'm not sure I'm using the right tool for the job here, but I'm trying to embed Lua syntax highlighting inside a block syntax. The only way I can make this work is with a syn region. I can find the ...
3
votes
1answer
53 views

Invalid syntax for a bash file called catalog

I have a file written in bash (with the she-bang) and called "catalog", and the syntax highlighting is incorrect. If I rename the file, the colors become correct. I have not configured anything in ...
3
votes
1answer
595 views

How can I remove a syntax keyword?

In Python3, file is no longer a builtin. It's just a plain ol' name that isn't even associated with anything until you do. But all the syntax files that I've used have it as a builtin. Is there a ...
3
votes
2answers
664 views

How to tell vim to behave the same for file extension .in and .mako

I noticed Vim will choose the correct syntax when I open a file that ends with .c.in or .pl.in. I would like to tell Vim to behave the same with extensions like .c.mako or .pl.mako. How is it ...
3
votes
2answers
1k views

Syntax highlight fail for Prolog files

I'm having trouble configuring Vim on Manjaro: After setting syntax on at .vimrc file, I make a Prolog program (bug.pl) which shows no syntax highlight: But after I append /**/ to top of file (then ...

1 2
3
4 5
12