找出 vim 中特定关键字/符号属于哪个突出显示组
我从 TextMate 转到 Vim,我想自定义我的 vim 颜色方案。如果我能找出任何特定单词或符号属于哪个突出显示组,那将非常有帮助。在 TextMate 中,我会将插入符号放在有问题的单词/符号上,然后按 ctrl-shift-p,然后会出现一个工具提示,内容如下:
text.html.basic meta.tag.structure.any.html string.quoted.double.html
根据此信息,编辑要应用的 TextMate 颜色主题非常简单(或删除)格式化相关文本。
在 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
From this information, it is really straightforward to edit a TextMate color theme to apply (or remove) formatting to the text in question.
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不确定我理解是否正确,但是您在寻找这个吗?
I'm not sure I understood right, but are you looking for this ?
获取有关突出显示的大量信息的另一种方法:
如果我将鼠标移动到 C 文件中的注释上并按 F3,我会得到:
这表明它位于突出显示组
cCommentStart,链接到
Comment
并以绿色显示 (#00ff00
)。这是(修改)自此处,请参阅该页面以获取更多信息。Another way to get lots of information about the highlighting:
If I move over a comment in a C file and press F3, I get:
which shows that it is in the highlight group
cCommentStart
, which is linked toComment
and coloured in green (#00ff00
). This is (modified) from here, see that page for more information.更新:来自
:help synID()
(参见示例):据我所知,您能做的最好的是:syntax,这将为您提供当前文件加载的所有语法的列表。我不知道有什么可以给出当前缓冲区的语法解析。
请注意,
:syntax
只是定义了语法项,它使用了:highlight 命令为语法项提供颜色。
一旦您决定要进行哪些更改,请将它们放入
~/.vim/after/syntax/.vim
中。这些将在加载默认语法文件后应用您的更改。UPDATE: From
:help synID()
(see the example):As far as I know, the best you can do is:syntax
, which will give you a listing of all the syntax loaded for the current file. I don't know of anything that will give the syntatical parsing of the current buffer.Note that
:syntax
just defines the syntax items, it's uses of the:highlight
command that give the coloring for a syntax item.Once you've decided what changes you want to make, put them in
~/.vim/after/syntax/<filetype>.vim
. These will apply your changes after the default syntax files are loaded.