正如"太多的PHP"所说,没有直接的方式来说"创造一个看起来像那个并加上大胆的价值".最好的方法是修改配色方案.如果您没有使用自定义配色方案,请将主vim安装目录中的一个复制到〜/ .vim/colors目录并编辑它以适合您.或者,搜索vim脚本页面并尝试其中一些可用的.
无耻的插件:如果你想要一个比标准格式更容易编辑,请尝试我的"强盗"配色方案.
如果你真的希望能够动态添加粗体,你需要一个相当复杂的脚本,如下所示.请注意,除非您在加载配色方案后自动调用它或执行以下操作,否则不会为下次会话保存此内容:
:autocmd ColorScheme AddBoldToGroup my_highlight_group
所有这些剧本的剧本如下.据我所知,没有明显更快的方法!显然,你可以通过编写更简洁的代码来节省几行,但是使用redir
和silent hi
重复使用的一般想法是唯一的方法.
" Call this with something like " " :AddBoldToGroup perlRepeat " command! -complete=highlight -nargs=1 AddBoldToGroup call AddBoldToGroup() function! AddBoldToGroup(group) " Redirect the output of the "hi" command into a variable " and find the highlighting redir => GroupDetails exe "silent hi " . a:group redir END " Resolve linked groups to find the root highlighting scheme while GroupDetails =~ "links to" let index = stridx(GroupDetails, "links to") + len("links to") let LinkedGroup = strpart(GroupDetails, index + 1) redir => GroupDetails exe "silent hi " . LinkedGroup redir END endwhile " Extract the highlighting details (the bit after "xxx") let MatchGroups = matchlist(GroupDetails, '\ \s\+\(.*\)') let ExistingHighlight = MatchGroups[1] " Check whether there's an existing gui= block let MatchGroups = matchlist(ExistingHighlight, '^\(.\{-}\) gui=\([^ ]\+\)\( .\{-}\)\?$') if MatchGroups != [] " If there is, check whether "bold" is already in it let StartHighlight = MatchGroups[1] let GuiHighlight = MatchGroups[2] let EndHighlight = MatchGroups[3] if GuiHighlight =~ '.*bold.*' " Already done return endif " Add "bold" to the gui block let GuiHighlight .= ',bold' let NewHighlight = StartHighlight . GuiHighlight . EndHighlight else " If there's no GUI block, just add one with bold in it let NewHighlight = ExistingHighlight . " gui=bold" endif " Create the highlighting group exe "hi " . a:group . " " NewHighlight endfunction