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
5
votes
2answers
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:...
0
votes
0answers
29 views

Create syntax filetype

I'm trying to create a syntax file for a new language/filetype. I followed this tutorial. Here is my (not complete) syntax file, created in directory ~/.vim/syntax/scad.vim: if exists("b:...
3
votes
1answer
234 views

How can I change Javascript syntax to higlight objects?

I am trying to emulate the Atom JavaScript syntax highlighting in vim, but there are a few things missing. Namely, I'd like to highlight objects and their chains in red. It'd be dandy if I could ...
0
votes
3answers
41 views

List/navigate specific syntax elements in a file?

I would like to jump through specific syntax elements in a file. For example, quickly navigate to the next string element. In a .vim file strings are defined as vimString syntax elements. For ...
0
votes
0answers
27 views

E254: Cannot allocate color SlateBlue

I just freshly installed vim via brew install vim... and presently have version 8.2.3450. In ~/.vimrc I have syntax on, and when I run vim, I get: E254: Cannot allocate color SlateBlue If I delete / ...
2
votes
1answer
91 views

How to change the color of the prefix "b", "r", "f" or "u" before strings?

Is there any way to do this ? I'm using vim 8.2 with this python plugin. The inside of f strings for example is correctly highlighted but not the "f"
0
votes
1answer
29 views

Using a vim syntax file, I would like some Keywords, such as ??, to be colored

I have been trying to get through the syntax file documentation on vim help, https://vimhelp.org/syntax.txt.html#%3Asyn-files but it's quite the read and I figured someone here may know how to go ...
0
votes
1answer
54 views

Syntax highlighting is incomplete on neovim, fixed by calling Telescope

I have this problem that I would really like to get to the bottom of. If I open a file on neovim it will display like the broken syntax highlighting, see image below. Now, If I run :Telescope ...
2
votes
1answer
148 views

Retrieve the match 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, ...
0
votes
1answer
37 views

Toggle specific highlight group

Is it possible to temporarily disable the text highlight under cursor? The current highlight group can be obtained by synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name'). How to clear it to ...
0
votes
2answers
38 views

What's missing to fold vimscript consecutive comments with "syntax" foldmethod inside function, if, while, etc?

This syntax region fold consecutive comments: syn region vimFoldComment \ start="^\z(\s*\"\)" \ end="\(\z1\)\@!" \ transparent fold ...
2
votes
1answer
33 views

Markdown lists items three levels or deeper are not syntax highlighted

In a Vim markdown file (:set filetype=markdown), special items such as links and itacized text are normally syntax highlighted, but when they appear in a list more than three levels deep, they appear ...
1
vote
1answer
20 views

Modify syntax highlighting dynamically

Is it possible to write a vim plugin that modifies buffer in real time? As a first step, would it for example be possible to modify syntax highlighting of unused variables as suggested in a similar ...
1
vote
1answer
185 views

folding in matlab

I'm using vim for my matlab editor. And It works nicely, except I cannot get folding to work. I found my syntax file on github: matlab.vim And I wanted to add folding. I changed the line syn ...
2
votes
2answers
48 views

Custom syntax highlighting: highlight match following keyword

This question might be related to Custom syntax highlighting: highlight word following keyword but after studying that for hours, I could not get it to work. What I want is to highlight vulkan types ...
0
votes
1answer
165 views

Fold: Different highlight style for fold of each filetype

Extend of this question of fold: Fold: foldtext() for each filetype We have fold for each filetype now but each fold need different highlight style of color, because highlight is global I tried to ...
5
votes
1answer
307 views

Interactive syntax-highligting: highlight the current region only

Often enough a text file is structured as a collection of blocks or cells of some kind. E.g., slides in a Tex Beamer presentation, bibtex items, function definitions, etc. I wonder if vim can ...
0
votes
2answers
48 views

Why does an empty vimrc file change my configuration (e.g. disable syntax highlighting)?

Here is the sshconfig syntax highlighting when i do not have any .vimrc file: Let's create an empty .virmc : $touch ~/.vimrc Now let's edit that same file again: Why is this happening? I'd like to ...
2
votes
1answer
28 views

Changing syntax highlight rules priority

I want Vim to highlight tags (#tag) in my Markdown files. I extended the default highlighting by creating ~/.vim/after/syntax/markdown.vim with the following content: syn match mdTag '#\w\+' hi link ...
0
votes
2answers
42 views

How do I use syntax-nextgroup in this custom syntax file?

Writing vim syntax files never ceases to make me feel like an idiot. I have a new custom language call jsond, and I wanted to get syntax highlighting working in vim. Using racket syntax works pretty ...
0
votes
1answer
36 views

Highlighting won't change when using hi def link

I'm trying to create a basic custom syntax file for the first time, but I noticed that after I set a highlight link it's basically set and I'm not really sure how to change it. Here is my syntax file: ...
0
votes
0answers
29 views

Why does my syntax highlighting disappear after so many splits?

I can successfully run :sp *filename* several times per vim session, but after a seemingly-random number of splits (5-10) all future splits will no longer have syntax highlighting until I fully quit ...
0
votes
1answer
36 views

Highlighting item in fold for custom markup language

I am trying to write custom syntax highlighting for a domain specific markup language for a simulator I am working on. I can get everything but one part working. A simple example would look something ...
2
votes
1answer
375 views

ruby syntax highlighting lost on long files

With a "long" ruby file (896 lines in my case) the ruby syntax highlighting is lost when I G to the bottom of the file. Once that happens and I go back to the top with gg, the syntax highlighting ...
3
votes
1answer
866 views

How to match paragraphs of text ending with a character?

This problem that seems trivial is beating me real hard. I'm trying to create a couple of syntax highlighting directives for a custom language that is structured in paragraphs separated by at least ...
1
vote
2answers
56 views

How to syntax-highlight part of a file in a foreign language?

Using set syntax=lang we can override syntax highlighting of current buffer with lang. Suppose we're editing a Bash script and some string variables are actually HTML code. How to force vim to use ...
1
vote
0answers
75 views

Using Vim as a syntax highlighting tool - Python and TeX interface

I am trying to modify Vim's syntax highlighting rules for Python to suit specific needs : in particular, I need to capture all the line after some regexps (^Out [.*]: and ^\h\w*Error:). After some ...
1
vote
1answer
42 views

in-place replacement of code in HTML documents with TOhtml?

I'm working on some old HTML documentation, where are multiple code snippets (several lines long). I need to replace this old HTML-ized code with new one using modern styling. What I have now: ... ... ...
0
votes
1answer
25 views

How do I view a regex and containedin of a group?

I'm wanting to see how groups were created and what they are contained in. What I'm doing now is this and then I search for the group. :Verbose syntax What I would like to do is this. :verbose syntax ...
0
votes
0answers
78 views

How do I make sure terminal vim has syntax highlighting with 'cursorline' and 'termguicolors'?

I searched this issue on the web to no avail and it's most likely not here too. The issue I'm facing goes like this I am trying to switch to vim since I find it cool. I was writing my vimrc and ...
0
votes
0answers
39 views

How to define keywords starting by '*' following by words in syntax file

I want to enable syntax highlighting for Calculix simulation software. The input text file is made of keywords starting by '*', such as *HEADING or NO ANALYSIS. The keyword starts the line and there ...
0
votes
1answer
172 views

Vim syntax line matching mechanism

Can someone explain or link to valid explanation information on the syntax highlighting mechanism. In particular I am having having a hard time understanding how rules are applied. Imagine the ...
1
vote
1answer
20 views

How to highlight a keyword juxtaposed to an alphabetic region start marker?

I have a syntax whereby #J indicates embedded JSON. This can be followed by any JSON object such as #J[1,2,3]. The atom cases (Boolean, null, number, string) are handled as a json_atom region. This ...
1
vote
1answer
52 views

How to use different rules for highlighting trailing whitespace inside a gitcommit diff

In my ~/.vimrc, I have: highlight TrailingWhitespace ctermbg=blue autocmd BufReadPost * syn match TrailingWhitespace /\s\+\%#\@<!$/ This highlights trailing spaces, except when I am still typing ...
1
vote
1answer
265 views

Vim to highlight functions and user-defined types

I have two scenarios where I want vim to highlight those items. Currently my fix for these are to add the return types directly into the after/syntax/c.vim file, but this gets incredibly tedious. Here ...
1
vote
0answers
33 views

Project local keyword highlighting

I want to enable syntax highlighting for custom types in C files. So, in order to highlight a type name MyCoolType, I add the following line to ~/.vim/after/syntax/c.vim: syn keyword Type MyCoolType ...
0
votes
1answer
36 views

Syntax highlighting for uppercase headings using === or --- syntax

In Vim, without using any markdown plugin, headings like # Uppercase heading # lowercase heading lowercase heading ================= lowercase heading ----------------- get highlighted, while ...
0
votes
0answers
29 views

How dose colorscheme file working when python.vim file not exist?

I deleted python.vim in ~./Vim/vim82/syntax directory, and define colorscheme.vim in ~./Vim/vim82/colors directory. The colorscheme.vim contain this code call <sid>hi('pythonNumber', s:...
0
votes
1answer
75 views

manually set syntax highlighting works from command-line mode but not from .vimrc/init.vim

The gruvbox colorscheme and syntax highlighting for C++ doesn't highlight some elements such as: string vector I have this: So I decided to change the colors manually using in init.vim syn keyword ...
0
votes
1answer
52 views

Cannot get rid of persisting highlighting

I switched from macos to linux and have spontaneous highlighting in my document. I tried to get rid of it by doing the following command without success: hi clear no syntax nohlsearch noh The ...
19
votes
3answers
13k 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 ...
2
votes
1answer
163 views

Concealing the code for `braket` package for LaTeX with vimtex + `tex-conceal`

I am using vimtex with latexmk and using conceal setting provided by vim and extending it with an additional plug-in : KeitaNakamura/tex-conceal.vim. Additionally, I use a package braket to encode \...
0
votes
1answer
23 views

How to put sync region start=<this> into a variable?

I have the following code: com! -nargs=* ShFoldFunctions <args> fold ShFoldFunctions syn region shFunctionOne start="^\s*[A-Za-z_0-9:,][-a-zA-Z_0-9:]*\s*()\_s*{" end="}&...
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}} %...
46
votes
5answers
16k 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 ...
10
votes
3answers
646 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....
0
votes
0answers
24 views

Enable syntax highlighting for files opened by quickfix commands like cc

After populating quickfix window using commands like :vimgrep, when I jump to a quickfix entry using cc <number>, if the file corresponding to that quickfix entry wasn't already opened in a ...
0
votes
1answer
22 views

Syntax Match PLSQL Label

A PLSQL Label uses this syntax <<LABEL_NAME>> How can I highlight everything inside and including the opening and closing angle braces? I've tried the following: syn match PLS_label "...

1
2 3 4 5
12