4

I'm new to vim and bumped into a problem.

Short question -- will vim tell me why it chose to highlight certain text in a certain way?

Long question --

I'm using vimdiff to compare two files, and the "DiffChange" highlight uses a purple background.

However, the files I'm diff'ing are puppet files, and there are quite a few possible highlights that show the text in the same purple color.

So what I'd really like to do is move to a specific character and have vim tell me "this character is subject to the following highlights" so that I know which one (for the text color) needs to be changed.

Is that possible?

1
  • 1
    I love how my question, dated Aug 4 2017, is now marked as a "closed / duplicate" of a question that is dated Jan 4 2019.
    – hymie
    Feb 9, 2021 at 19:00

1 Answer 1

3

from my .vimrc (all in one line):

nnoremap <M-i> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID(line("."),col("."),0),"name") ."> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>

move to your character and press Alt-i.

You may want to choose a different key for this mapping.

1
  • 1
    What is the difference between hi, trans and lo
    – 0fnt
    Mar 4, 2019 at 11:26

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