gpt4 book ai didi

vim - 我想自定义折叠折叠中显示的文本 vim

转载 作者:行者123 更新时间:2023-12-04 18:27:13 25 4
gpt4 key购买 nike

我使用折叠来评论

#
Stuff between the # are comments and automatically folded
#

折叠起来是这样的

+--  4 lines: #--------------------------------------------------------------

我宁愿让他们说

+-- 4 Stuff between the # are comments and automatically folded

并且不会突出显示,或者在我的黑色终端上使它们成为白色背景。

我认为它是 foldtext 变量,正则表达式超出了我的范围。

最佳答案

除了方法 ZyX 显示,您还可以分配一个单独的函数来构建文本,如果您想进行更复杂的处理,这将特别有用。例如,

setlocal foldtext=MyFoldText()

function! MyFoldText()
" do whatever processing you want here
" the function will be called for each folded line visible on screen
" the line number of each fold's "head" line will be in v:foldstart
" last line of fold in v:foldend
" can do whatever processing you want, then return text you want
" displayed:

return my_processed_fold_text

endfunction

就高亮而言,折叠文本的整行将具有相同的高亮,这是由“折叠”高亮组决定的。因此,如果您希望它们是黑底白字:

:hi Folded guifg=white guibg=black ctermfg=white ctermbg=black

或者如果您希望它们以灰白色斜体显示:

:hi Folded guifg=#bbbbbb guibg=black gui=italic ctermfg=white ctermbg=black

关于vim - 我想自定义折叠折叠中显示的文本 vim,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4009979/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com