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

Can I show a color from its hex value in *any* file?

We have vim-css-color to display colors in .css files. Currently I'm editing my i3wm config to match colors to a new terminal theme and it would be quite handy to be able to actually see colors I'm ...
4
votes
1answer
334 views

Printing syntax highlighting in ex-mode

If I start vim in Ex-mode, I can have it print the entire file with %print, but it just prints the raw text. Is there a command I can use to get it to print the file with syntax highlighting?
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
122 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
593 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
80 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
793 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
1answer
629 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 ...
4
votes
1answer
96 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
580 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
413 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
267 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
514 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
338 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
768 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
904 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
454 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
231 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
101 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
176 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
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
102 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
61 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
537 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 ...
4
votes
0answers
361 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
768 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
333 views

Can I use syntax highlighting on an unwritten buffer?

I pasted some code into a new, unwritten buffer in Vim. I'd like to do some quick edits on the code without saving it to a file, but it hurts my eyes to look at code without syntax highlighting. Can ...
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
529 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
921 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
1k 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
339 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
693 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
143 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
184 views

How to setup vim-clojure-highlight to work?

I've been trying to setup my Clojure dev environment with Vim, note that I'm still very new to vim but I've managed to know the basics. I've installed pathogen which has helped me get a bunch of ...
3
votes
1answer
154 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
802 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
841 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
178 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
615 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
228 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
84 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
729 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
430 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 ...

1 2
3
4 5
12