找出特定关键字/符号在 vim 中属于哪个高亮组 [英] Find out to which highlight-group a particular keyword/symbol belongs in vim
问题描述
我从 TextMate 来到 Vim,我想自定义我的 vim 配色方案.如果我能找出任何特定单词或符号属于哪个突出显示组,那将非常有帮助.在 TextMate 中,我会将插入符号放在有问题的单词/符号上,然后按 ctrl-shift-p,然后会出现一个工具提示,内容如下:
I am coming to Vim from TextMate, and I would like to customise my vim colorscheme. It would be really helpful if I could find out to which highlight-group(s) any particular word or symbol belongs. In TextMate, I would place the caret on the word/symbol in question, then hit ctrl-shift-p and a tool tip would appear saying something like:
text.html.basic
meta.tag.structure.any.html
string.quoted.double.html
根据这些信息,编辑 TextMate 颜色主题以对相关文本应用(或删除)格式非常简单.
From this information, it is really straightforward to edit a TextMate color theme to apply (or remove) formatting to the text in question.
在 Vim 中,如果我想更改某个单词或符号的格式,我不知道从哪里开始.有什么等同于 TextMate 的 ctrl-shift-p 吗?
In Vim, if I want to change formatting for a certain word or symbol, I'm not sure where to start. Is there anything equivalent to TextMate's ctrl-shift-p?
推荐答案
我不确定我是否理解正确,但是您在寻找这个吗?
I'm not sure I understood right, but are you looking for this ?
" adds to statusline
set laststatus=2
set statusline+=%{synIDattr(synID(line('.'),col('.'),1),'name')}
" a little more informative version of the above
nmap <Leader>sI :call <SID>SynStack()<CR>
function! <SID>SynStack()
if !exists("*synstack")
return
endif
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfunc
这篇关于找出特定关键字/符号在 vim 中属于哪个高亮组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!