I want to design my own vim color scheme, so I'm starting with an existing color scheme that I think is pretty good, and fixing the parts I don't like.

The color scheme definition contains many syntax tags, a lot of which aren't totally clear. The task would be much easier if I could ask Vim:

Which syntax rule is determining the color of the character under my cursor?

Is there a way to do it?

1 Answer 1


There are plenty. One is my own plugin, the code of which is straightforward:

" Show the highlight groups under the cursor
" Maintainer:       David Ben Knoble <[email protected]>
" Last Change:      2018 May 11

if !has("syntax") || &compatible
  echohl ErrorMsg
  echomsg "vim-synstax requires the +syntax features"
  echohl None

function! synstax#UnderCursor() abort
  let l:stack = synstax#Stack(line('.'), col('.'))
  if empty(l:stack)
    return "No syntax highlight groups under cursor"
  let l:names = synstax#Attributes(l:stack, 'name')
  return l:names

function! synstax#Stack(line, col) abort
  return synstack(a:line, a:col)

function! synstax#Attributes(stack, attr) abort
  let l:attr_func = printf('synIDattr(v:val, "%s")', a:attr)
  return map(a:stack, l:attr_func)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.