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

Using set listchars, what are 'extends' and 'precedes'?

Searching for a solution to show hidden characters, I found the example, :set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:< :set list What are extends and precedes? I expected a ...
6
votes
2answers
420 views

Define syntax in only one line

I would like the first line of some documents I have to be highlighted as a comment. I would like something like: syntax match myTypeComment /{apply only to first line}^.*$/ But I don't know how ...
6
votes
1answer
818 views

Vim to highlight only a submatch

Folks, I'm writing a syntax highlighting script for vim, but I'm struggling on how to highlight only a submatch of a pattern. For example, suppose that I want to highlight any number within #, like #...
6
votes
2answers
3k views

How to avoid "Avoid E173 (n more file(s) to edit)?"

So, when I open multiple files, but don't visit the all of them (or the last one), and I try to :quit neovim yells at me that I have to edit those files. No I don't! Stop giving me this error : ) It ...
6
votes
1answer
1k views

Why doesn't Vim recognize HTML inside PHP?

The HTML that's being returned by this PHP function doesn't have any syntax highlighting. If I delete the ' on line 13 the HTML highlighting works (but the PHP function breaks), with it the HTML ...
6
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 "...
6
votes
1answer
469 views

Highlight heredoc as perl code

I would like to highlight all the HereDocs in a particular perl file as perl code. For example, I'd like to apply the normal perl highlighting to the subroutine in this HereDoc: my $code = <<'...
6
votes
4answers
5k views

Colorizing plain text

I love vim, i use it all the time for write codes, but now I want to write some personal notes. I'm trying vim-pandoc (with vim-pandoc-syntax) and it's nice to have 'rich text' features like titles, ...
6
votes
1answer
616 views

Why don't I get syntax highlighting when I open a file in an autocmd?

While trying to devise a solution to How do I make vim look in a set of directories for a file, if it doesn't exist in the current directory?, I have got so far using Python: function LookupFiles ...
6
votes
2answers
913 views

Highlighting another syntax in a shell heredoc

I edited my original question and title to broaden its scope to any syntax - with SQL used as just an example. You can adapt the examples and the answer to other languages. By adding suitable ...
6
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 ...
6
votes
2answers
385 views

Syntax file: keywords within context

I have a language which uses statement like WHILE ... DO .. END_WHILE I can do the following in the corresponding synthax file syn keyword LangKeys WHILE DO END_WHILE syn region LangBlock start="...
6
votes
0answers
302 views

.php file makes html text same color as html attributes - how to fix?

The text inside of <p> tags is the same color as the html attributes, so it's hard to distinguish between them. The html inside this .php file is colored (line one of this image) almost ...
5
votes
1answer
3k views

How to set value of cterm to both bold and underline?

Currently, my vimrc has set cursorline hi CursorLine cterm=underline ctermbg=none ctermfg=none I want to be set cterm to both underline and bold
5
votes
1answer
4k views

Custom syntax highlighting: highlight word following keyword

I am currently trying to set a custom syntax highlighting using a mysyntax.vim file. I have several keywords (int, real, real2D, real1D, etc) currently highlighted using syn keyword VariableType real ...
5
votes
1answer
1k views

Personal syntax highlighting

I tried to change the syntax highlighting, by copying /usr/share/vim/vim74/syntax/html.vim to ~/.vim/after/syntax/html.vim. Then I changed the syntax highlighting file, but I don't see any changes. ...
5
votes
2answers
528 views

Vim syntax highlighting for ChatScript language?

I'm looking for a ChatScript language Syntax highlighting, of course for the Vim editor. ChatScript is a great (underrated) open-source language to build chatbots dialog flows scripts, made by Bruce ...
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 ...
5
votes
1answer
182 views

MacVim thinks I have unmatching parentheses, until I place cursor over each parenthesis

I am trying out MacVim for the first time and Vim seems to think I have a surplus of closing parentheses: However, Vim seems to change it's mind. Each highlighted closing parenthesis is no longer ...
5
votes
1answer
697 views

Highlight double space in markdown

When writing markdown, a double space at the end of a line indicates a line break. Currently, neither single trailing whitespaces nor double-whitespaces are being highlighted. Is it possible to have ...
5
votes
2answers
712 views

Vim `cpp` Syntax highlighter prematurely ends macros mid-word

NOTE: This question is a "manual migration" from here: https://superuser.com/q/875751/199803 My Vim syntax highlighter for ft=cpp is prematurely ending some macros mid-line. For example: (The ...
5
votes
1answer
88 views

Disable spell checking for URLs in BibTeX

I would like to disable spell checking for the URLs in my BibTeX (.bib) files. I was able to disable spell checking for the citation keys (author-year or author+year) as follows: autocmd FileType bib \...
5
votes
1answer
918 views

What does the command `:syntax reset` do?

from the help: :h syntax-reset If you have changed the colors and messed them up, use this command to get the defaults back: > :syntax reset It is a bit of a wrong name, since it does ...
5
votes
3answers
2k 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 ...
5
votes
1answer
650 views

Highlighting with :match does not appear in all buffers

I wanted to highlight all occurence of TODO and NOTE in my code. Looking on the internet, I inserted the following code in my .vimrc :match GruvboxGreenBold /NOTE/ :2match ErrorMsg /TODO/ This ...
5
votes
3answers
1k views

Improve performance of syntax highlighting in Vim

I have some C++ sources files which are in a few mega-bytes (a few tens thousands lines) to view and edit. The performance looks really bad in Vim. Refersh (<C-l>) or input single char in insert ...
5
votes
1answer
351 views

How can I make text formatting ignore concealed characters?

Question Working with text and various markup languages in Vim I have recently experimented with the conceal feature to hide some of the more verbose markup. I switch conceal off when writing and ...
5
votes
2answers
666 views

Entering search pattern with syntax highlighting?

A search pattern used with /, entered on the vim command line, can be very complex. But even for a normal regular expression pattern, syntax highlight of the expression syntax would be helpful. ...
5
votes
1answer
764 views

Why I am losing syntax highlighting when folding code within a <script> tag?

I am working with an HTML file and within a <script> tag specifically. I usually fold my code using the marker method. However an annoying behavior sometimes happens with my syntax highlighting ...
5
votes
1answer
2k views

How can I highlight all function names in Python files?

I try to make python.vim color similar to material theme (sublime text 3), see pictures: https://imgur.com/a/wOgH7 expected is material theme and current is mine. You may noticed that all method, ...
5
votes
1answer
690 views

What are the global settings for syntax highlighting?

I'm troubleshooting syntax highlighting in my .vimrc settings. My setup is a little complex because I have some filetype settings for plain text and other settings for programming files (using ...
5
votes
1answer
2k views

Tmux messing with Vim highlighting [duplicate]

When I load up vim inside tmux there is a background color behind all text as so: If I load it up not in tmux I get the following: I want it to be like image 2, I can not understand why tmux is ...
5
votes
1answer
2k views

Change default syntax highlighting scheme

I'm unhappy with the default syntax highlighting in vim and would like to change it. I tried to follow the accepted answer on this page, but I think my vim version (7.4) is different. Inside /usr/...
5
votes
1answer
474 views

How to make a syntax region stop on empty lines?

I would like to adapt this syntax file so that the formatting in VIM matches more closely what this online Markdown editor (GitLab-flavor) displays (the output on the right is relevant, this is how I ...
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:...
5
votes
0answers
123 views

How can I test and debug my syntax files?

I'm trying to make a syntax file for Raku. The major challenge I'm running into is that I have no automated means to test that my highlighting works as expected. I have to keep another tab open, ...
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 ...
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 ...
4
votes
1answer
2k views

Visual Differences between vim on virtualbox Ubuntu guest (through putty) OR gVim on Windows host

Ok, it's a curiosity more than a real question, I apologize in advance for long post: Usually I code with vim on a ubuntu headless, as a virtualbox guest on my stupid windows 7 host; I access linux ...
4
votes
1answer
252 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 ...
4
votes
2answers
1k views

How to check the syntax of a file on the fly?

For those who might not know, Flycheck is a plugin which checks the syntax of the code you're writing on the fly, without forcing you to save the file. It does that by periodically saving the buffer ...
4
votes
2answers
793 views

How to jump to the end of quoted string, considering escaped delimiters

Assuming the following situation $someVar = "Some String with \"escaped\" inner delimiters"; with the cursor somewhere in the double-quote delimited string. What is the quickest way to jump to the ...
4
votes
1answer
61 views

Syntax coloring is inaccurate for HTML files with CSS code in it

As you can see in the following screencast, when I open an HTML file with some CSS in it, there's some part of the file which does not show syntax coloring. Do you have experience of this? Is it ...
4
votes
1answer
291 views

Re-sync _folds_ from start

Vim has a handy feature in :syntax sync fromstart which allows me to fix syntax highlighting when it gets confused during an extended editing session. I map it to <leader>ss (reSync from Start) ...
4
votes
2answers
3k 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
152 views

Start of match \zs seems to break my pattern

I am playing around with vim syntax, matching expressions like name.subname regardless of their layout. Here is a match pattern I came upon which does exactly what I want: Now, I wish that subname ...
4
votes
1answer
1k views

syntax highlight for whole line

I want to color the background of a keyword but also for the whole line where it is found. The file has entries like this: \begin{frame} \frametitle{title} \framesubtitle{subtile} \end{frame} Lines ...
4
votes
2answers
1k views

Highlight XML errors based on this XML file's XML Schema

I have an XML file that must conform to a particular XML Schema: <?xml version="1.0" encoding="UTF-8"?> <myroot xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
4
votes
1answer
55 views

How to get syntactic coloration for dist files

There is a standard for providing files that may have an unversioned counterpart. That standard consists in suffixing the filename with .dist, so for example phpunit.xml becomes phpunit.xml.dist. How ...
4
votes
1answer
395 views

Vim highlighting random indentations

As seen from the image, Vim decides to highlight those indentations for no reason. I've tried :noh and :set nolist (:set list seems to make it go away, but I don't want indentation marks) from a ...

1
2
3 4 5
12