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.
678
questions
1
vote
0
answers
39
views
define a match group for a modeline
Looking to define a match group for modelines. vim defines two patterns for modelines:
The first form:
[text{white}]{vi:|vim:|ex:}[white]{options}
[text{white}] empty or any text followed by at least ...
0
votes
1
answer
18
views
set syntax color to log files, .env.local files without detected extension
sometimes, vim don't color text because file haven't got extension or the right extension, like /var/log/syslog.1, or .env.local
How to define color syntax temporarily or definitely ?
How to know ...
1
vote
1
answer
19
views
if endif oneliner failure in VIM
I followed QA_1.
I use vim 9.1.0 instead of nvim which seems to also have the following bug and I have the following in foo.vim at line 67:
if g:LOG_MSG==v:true | echow "g:mode_class " | ...
0
votes
1
answer
12
views
Setting guard variables does not prevent default ftplugin/syntax/indent files from running
I want to prevent the default ftplugin/syntax/indent files from running for tex files.
I have a tex.vim in the $XDG_CONFIG_HOME/nvim/ftplugin directory, i confirmed it runs before the default ftplugin/...
1
vote
2
answers
31
views
Easy way to change the background color of a line
I understand that vim can set syntax for highlighting by defining the classes.
However, this is a bit tedious.
Is there an easy way to change the background of a line, e.g. is there a way by writing
...
0
votes
1
answer
28
views
Vim highlighting bug
I'm new to Vim and having problems with highlighting for TypeScript. It seems like at some point, the syntax highlighting just stops behaving correctly. As you can see in the picture, each "i&...
3
votes
1
answer
50
views
How to use syntax rules to disable spell checking certain regions?
Vim has a built in capability to spell check files (see :help spell). This spell checking is syntax aware (see :help syn-spell). Unfortunately, I have no experience writing syntax rules for ...
1
vote
1
answer
38
views
Add new filetype syntax to markdown code fence [duplicate]
For work I use a certain SQL-like DSL. We'll call it lang. I write my docs in vim(wiki), and these docs contain a lot of lang snippets. I have written my simple syntax highlight rules for lang, and ...
9
votes
2
answers
2k
views
Conceal passwords in configuration files but maintain password length
Preamble
I often share my screen with other developers over discord. When I navigate to a .env file that has sensitive information, I'd like to conceal that information while still allowing others to ...
1
vote
1
answer
54
views
Extending existing syntax highlighting system-wide
I’m trying to figure out a way to extend existing syntax highlighting in a way that can be packaged and shipped (ie., not placed under $HOME)—or whether this is possible at all.
For this specific ...
1
vote
1
answer
27
views
Is there a way to override filetype syntax?
I have a file.conf that has jsonc data. I tried the following hints at the beginning of the file:
// vim: ft=jsonc
and
# vim: ft=jsonc
but it has no effect, the filetype is still set to conf.
I know ...
1
vote
1
answer
70
views
Highlight link description in vimwiki
I'm trying to customize the colorscheme One for Markdown under Vimwiki.
I'd like to change the color of the Description in [Description](URL).
In my .vimrc I have the following relevant lines:
call ...
1
vote
1
answer
56
views
Syntax highlight for .tpl / cloud-config / cloud-init files
I am using cloud-init to parametrize cloud clusters. This is achieved via #cloud-config files, which usually have a .tpl or .tf.tpl extension. Here are a few examples, one of them illustrated below:
#...
0
votes
1
answer
36
views
Text randomly shown in italics after being sent to a REPL with iron.nvim
Some parts of my code, apparently at random, are rendered in italics, and when I type it goes back and forth from italics to normal.
Why is that and how I can avoid that?
EDIT: Contrary to what I ...
1
vote
2
answers
48
views
In gVim 9.1 how to have different backgrounds for text and the empty area to the right of <EOL>, with hlsearch ans syntax highlight still working?
I would like to use two different backgrounds colors bg1 and bg2 with:
bg1 for all text on a line (possibly nothing if line is empty) up to the end-of-line,
bg2 for the empty area after the end-of-...
3
votes
2
answers
99
views
Vimdiff bad line alignment and subsequent diff visualization
Let's say I have two files with the following contents:
this is some important text
another different line
if another is needed
here it is
and
this is some important text
we now first add two new ...
1
vote
1
answer
106
views
How can I enable highlighting such that all Python variables use the same color?
When I was using VSCode as my main code editor, many extensions like The One Dark Pro theme offered variable highlighting.
This is not Semantic highlighting, where each variable is assigned its own ...
0
votes
0
answers
48
views
Remove Vim highlighting on double quotes
I have syntax highlighting enabled so that I can change my comment colors in Vim. However, I don't want Vim to highlight something like this
"text here, including the speech marks get ...
0
votes
1
answer
75
views
How to customize comment?
For a specific type of file, want to define customized comment with below requirements.
Comment is start with -comment.
Comment content is surround by curly brackets { }.
Only show comment content ...
1
vote
1
answer
63
views
Vim in tmux and WSL: cannot highlight using ctermbg
I'm using Vim inside tmux, which runs in WSL (due to work reasons). As per documentation, I decided to change my Visual highlighting style using :hi cterm=NONE ctermbg=<insert-color-here>. ...
0
votes
1
answer
55
views
How to apply a specific syntax to a range within a file?
My cypher files are properly highlighted, however I have python files that include large texts of cypher like so
I would like the cypher part to be have the same cypher syntax highlighting like so
I ...
1
vote
1
answer
52
views
Disable syntax expansion on cursor hover
I use Neovim with Vimwiki for a personal wiki of mine. I frequently use its syntax for changing typeface; for example _ _ for italic and * * for bold.
The syntax is expanded when the cursor is on a ...
1
vote
1
answer
68
views
How to replace the default python syntax in Neovim without a plugin manager?
As the title, I would like to replace the default python syntax with the more modern one in https://github.com/vim-python/python-syntax.
I managed to do this in Neovim 0.9.4 with the vim-plug plugin ...
2
votes
1
answer
73
views
syntax coloring does not work for flex file
I'm using nord theme, it works normally with other kind of files but not flex file
I have syntax on and filetype on
I tried switching colorthing from gruvbox to nord but it still behaving the same.
...
1
vote
2
answers
90
views
How can I extend syntax highlighting with my own keywords?
I already have syntax highlighting for javascript, but what I'd like to do is extend it with some additional rules.
What I've been trying to start, is using highlight "Prototype" with a cyan ...
2
votes
0
answers
40
views
Syntax match only within a particular region (but also within other nested ones)
Is it possible to get VIM to recognize syntax changes inside a particular region? Specifically, I am trying to get LaTeX3's \ExplSyntaxOn...\ExplSyntaxOff syntax to be highlighted, but only inside a ...
1
vote
1
answer
570
views
How to disable lsp server syntax highlighting?
I found out that my lsp servers is somehow adding this ugly highlighting to my code (this happened after I updated my Homebrew for some reason), here are before and after pics:
Here is my lsp server ...
0
votes
0
answers
15
views
Syntax match array of builtin types
I'm writing a syntax file for Solidity files.
Solidity has several built-in types, such as uint8, uint16, ..., uint256, bytes1, bytes2, ... bytes32, etc.
One can have arrays for pretty much all types ...
1
vote
0
answers
51
views
How to distinguish between built-in and user-defined functions in Vim syntax highlighting for C?
I'm currently using the following code in my c.vim to highlight function names in C:
syn match cUserFunction "\<\h\w*\>\(\s\|\n\)*("me=e-1 contains=cParen,cCppParen
hi def link ...
1
vote
1
answer
64
views
Set different colours for different HTML tags
Can we set different colours for different tags in HTML syntax? For example, set a tags to green and div tags to yellow. In VsCode this extension makes HTML tags coloured inside .html, .jsx, .tsx and ...
2
votes
1
answer
43
views
Fixing JSON highlighting refresh
When I manually edit json files, I end up with red boxes falsely alerting me to syntax problems until I take manual action to refresh those lines.
I start with a file with a key/value pair:
{
&...
3
votes
1
answer
90
views
Vim syntax highlighting: conceal does not work when opening files from netrw
I use Vim version 8.2.4919 without 3rd party plug-ins on Ubuntu 22.04.2 LTS running via WSL2.
I want to have italic syntax highlighting for words encapsulated in underscores in comments of my cpp ...
1
vote
1
answer
34
views
Different Context Mode for highlight group
I can define different highlight groups for different documents.
For example,
in a general text document, I would define highlight groups as Header1,
Header2, Header3, and Normal Text, with different ...
1
vote
1
answer
39
views
How to use different font size for different highlight group?
There is a similar question gVim - Use different fonts using :highlight but no answer yet.
In short, is it possible to apply different font size to different highlight group?
For example, while normal ...
1
vote
0
answers
112
views
How to prevent the ansible format from getting overwritten?
I am using this plugin for ansible: ansible-vim, I am installing it with lazy like this:
return {
'pearofducks/ansible-vim',
build = 'UltiSnips/generate.sh',
lazy = false
}
When opening a file ...
0
votes
1
answer
66
views
I've switched to nvim and init.lua, which pulls in onedark colorscheme. How can I add a custom rule?
I have C-style comments inside PHP strings that contain SQL code, so I can easily understand what the query is doing when I see it running on the server.
DB::runQuery('/* this is my SUPER complicated ...
1
vote
0
answers
23
views
How to add a syntax rule to LaTeX filetype?
How can I colorize elements of the regex rule "\w\+:\w\+:\d\{4\}" in a LaTeX file ?
If I open a new document with no filetype and add the two following command :
syn match Bib3Dots '\w\+:\w\+...
1
vote
0
answers
71
views
\zs not working in syntax file?
Udated 2023-09-11: Changed example to asterisk as it is simpler and the question now refers to \zs instead of \ze as \zs seems to be the issue.
I am trying to adapt the VIM Markdown syntax file so ...
0
votes
0
answers
139
views
What options do I have to give time-only (i.e dependent on a call to a DB via http) dependent coloring to the words matching a regex?
Say the special strings are those matching the regex \<prefix[0-9]\+\>, and say that an HTTP request I can do via system can tell me that that item is in one of three states, Green, Red, or Blue....
0
votes
1
answer
119
views
MacOS - Vim overriding my highlight config in ~/.vimrc
~/.vimrc:
set backspace=2
set nocompatible
set clipboard^=unnamed,unnamedplus
syntax on
set expandtab tabstop=2 shiftwidth=2
set smartindent
set hlsearch
set incsearch
set ignorecase
set number
...
1
vote
1
answer
54
views
Conceal highlighting not applying to Vim help files
The Conceal highlighting is not working properly when I edit a Vim help file. When I'm in insert mode on a line with concealed text, the concealed characters will be black on black. I can only see ...
1
vote
1
answer
52
views
Syntax highlighting of a submatch
I have the following
syn match specialNumber /1/ contained
syn match normalNumber /\d/ contained
syn match line /^\d$/ contains=specialNumber,normalNumber
hi def link ...
0
votes
1
answer
73
views
External syntax highlighting
Is there a way (even theoretical) for Vim to use an external program for syntax highlighting?
For instance a program that reads buffer content from stdin and prints single-character colour identifiers ...
0
votes
1
answer
36
views
Cross-compiled Vim on ARM - only colours are bold, & underline
I cross-compiled Vim 9.0 for ARM / arm-linux-gnueabihf
(after also cross-compiling ncurses):
# ac_cv_sizeof_int=4 \
vim_cv_getcwd_broken=no \
vim_cv_memmove_handles_overlap=yes \
...
3
votes
1
answer
102
views
Do not red underline unicode control points as misspelled words
Vim highlights Unicode control points as misspelled words. So correctly spelled words with Unicode strikethrough (overline, ...) always appear misspelled. Ideally this would be corrected as a setting ...
1
vote
1
answer
73
views
Proper regex to prevent a match when keyword is preceded by a period
I'm writing a color syntax highlighting file for a derivative of Pick Basic. Two of the oddities that this language allows is periods in variable names and embedding a keyword in a variable name, ...
0
votes
1
answer
37
views
Is there a way to apply syntax highlighting to the results of :g?
I do a lot of work with log files, and I use a lot of hi def foo and syn match foo in my .vimrc. Is there a way to apply that syntax formatting to the results of a :g command?
0
votes
1
answer
55
views
Block comment syntax colouring being lost while moving, but redraw will fix
I frequently use block comments to disable sections of terraform code using /* to start disabling and */ to complete. As expected, the code will turn "grey" and lose syntax highlights.
...
0
votes
1
answer
391
views
TSEnable highlight - true by default
I'm using the plugin 'nvim-treesitter/nvim-treesitter', and I can enable syntax highlighting by using the command:
:TSEnable highlight
However, once I close n/vim it reverts back to disabled. I'm ...
1
vote
2
answers
975
views
Is there a way to disable Treesitter in Telescope?
I have max file size rule for files, setup in treesitter config, it works:
require 'nvim-treesitter.configs'.setup {
highlight = {
enable = true,
is_supported = function()
if vim.fn.strwidth(...