Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim syntax highlighting of a Python formatted string

Tags:

python

syntax

vim

I am using Vim 8.1 on Debian 11 Bullseye, but it does not work in the recent Vim 8.2 either.

I would like to syntax highlight a Python formatted string, which looks currently in vim so:

is

but should look like this:

should

(compare the curly braces and their content)

Does anyone know of a plugin that does this "properly", or can provide the syntax I need to insert in /usr/share/vim/vim81/syntax/python.vim to achieve this highlighting?

like image 526
nst0022 Avatar asked Oct 15 '25 15:10

nst0022


1 Answers

There is an appropriate highlighter on github: https://github.com/vim-python/python-syntax

In .vimrc, you need to enable either everything with

let g:python_highlight_all = 1

or specifics, like I did:

let g:python_highlight_string_format = 1
let g:python_highlight_builtin_objs  = 1

A python formatted string now looks like:

enter image description here

(with my color definitions)

like image 123
nst0022 Avatar answered Oct 17 '25 04:10

nst0022



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!