1

This question already has an answer here:

I try to harmonize the colors of my Vim and Emacs. But I am not sure how to map some Emacs faces to Vim. Emacs distinguishes between keyword and builtin. In shell mode if and case are of the type keyword, but alias is a builtin. I try to find the equivalent types. In Emacs I can use the function describe-face to inspect the faces in a buffer. How to do the same in Vim? All I found so far is the following list: https://github.com/vim/vim/blob/master/runtime/syntax/syncolor.vim

This is the list. Some are easy, because they have the same name. But some are not obvious.

Emacs                       Vim
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
font-lock-builtin-face      ?
font-lock-comment-face      Comment
font-lock-constant-face     Constant
font-lock-function-face     Function
font-lock-keyword-face      Statement
font-lock-string-face       String
font-lock-type-face         Type
font-lock-variable-face     Identifier
sh-quoted-exec              ?

Questions:

  1. What is the match for builtin and sh-quoted-exec?
  2. What is the Vim name for the color of sub shells? $()
  3. What is the Vim name for punctuation? .;[]
  4. What is the difference in Vim between the option in shopt -s and [ -f? They do not have the same color.

marked as duplicate by statox Jul 24 at 13:26

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • If you’re hoping to syntax highlight sh code, be warned, it’s not as robust as you think – D. Ben Knoble Jul 24 at 12:44
  • 1
    I think your question is a duplicate of Interactively check given string highlight group – statox Jul 24 at 12:45
  • (I’m looking for a QA i saw months ago about sh syntax hl and -options.) – D. Ben Knoble Jul 24 at 12:48
  • @statox :hi shows all faces. How to get the name of the face at the current cursor position? – ceving Jul 24 at 13:17
  • 1
    @statox Yes I think so. – ceving Jul 24 at 13:25
0

I added the following function to my emacs.vim:

" Inspect Emacs colors with:
" M-x describe-face
" Inspect Vim colors with:
function DescribeFace()
  let l:s = synID(line('.'), col('.'), 1)
  let l:r = synIDattr(l:s, 'name')
  while 1
    let l:st = synIDtrans(l:s)
    if l:s == l:st
      break
    endif
    let l:r .= ' ▷ ' . synIDattr(l:st, 'name')
    let l:s = l:st
  endwhile
  echo l:r
endfunction
command DescribeFace call DescribeFace()

The function displays the name of the syntax at the current point and all ancestors.

BTW: this was very useful: https://devhints.io/vimscript

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