Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/vim/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unix Vim:完成自定义折叠功能,需要自定义高亮显示_Unix_Vim_Function_Syntax Highlighting - Fatal编程技术网

Unix Vim:完成自定义折叠功能,需要自定义高亮显示

Unix Vim:完成自定义折叠功能,需要自定义高亮显示,unix,vim,function,syntax-highlighting,Unix,Vim,Function,Syntax Highlighting,我在vim中定义了一个函数,用于正确缩进折叠。也就是说,它们看起来像这样: 展开 使用默认函数折叠 被我的新功能折服了 唯一的问题是高亮显示仍然是这样的: 使用我的新功能折叠(用标记突出显示) 但这使得褶皱变得不那么明显 我尝试了以下几种变体: syn keyword Folded lines syn region Folded ... 但是我认为折叠的选择不同,我想不出替代默认高亮显示的方法。有人能提个建议吗 顺便说一下,这是我缩进折叠的功能: set foldmethod=indent

我在vim中定义了一个函数,用于正确缩进折叠。也就是说,它们看起来像这样:

展开 使用默认函数折叠 被我的新功能折服了 唯一的问题是高亮显示仍然是这样的:

使用我的新功能折叠(用标记突出显示) 但这使得褶皱变得不那么明显

我尝试了以下几种变体:

syn keyword Folded lines
syn region Folded ...
但是我认为折叠的选择不同,我想不出替代默认高亮显示的方法。有人能提个建议吗

顺便说一下,这是我缩进折叠的功能:

set foldmethod=indent

function! MyFoldText()
        let lines = 1 + v:foldend - v:foldstart
        let ind = indent(v:foldstart)

        let spaces = ''
        let i = 0
        while i < ind
                let i = i+1
                let spaces = spaces . ' '
        endwhile

        let linestxt = 'lines'
        if lines == 1
                linestxt = 'line'
        endif

        return spaces . '+' . v:folddashes . ' '. lines . ' ' . linestxt . ': ' . getline(v:foldstaendfunction
endfunction


au BufWinEnter,BufRead,BufNewFile * set foldtext=MyFoldText()
set foldmethod=indent
功能!MyFoldText()
让线=1+v:foldend-v:foldstart
let ind=缩进(v:foldstart)
设空格=“”
设i=0
当我
设i=i+1
让空格=空格
循环结束
让linestxt='lines'
如果行==1
linestxt='line'
恩迪夫
返回空格。“+”。v:folddashes。台词。linestxt.“:”。getline(v:foldstaendfunction
端功能
au BUFWANTER、BufRead、BufNewFile*集合foldtext=MyFoldText()
顺便说一句,谢谢你帮我设置这个函数

注意:我已经交叉发布了这个问题。

见问题

似乎我们无法控制折叠突出显示,因为它不是文件的一部分,而是在折叠处临时形成和放置的。

+1:感谢链接。这就是我所怀疑的。我将把这个问题留待几天(希望有人有窍门)。否则我将接受你的回答。
this is text 
also text
    ++- 2 lines: indented text ----------------------------
not indented text
this is text 
also text
<hi>    ++- 2 lines: indented text ----------------------------</hi>
not indented text
highlight Folded ctermbg=black ctermfg=white cterm=bold
syn keyword Folded lines
syn region Folded ...
set foldmethod=indent

function! MyFoldText()
        let lines = 1 + v:foldend - v:foldstart
        let ind = indent(v:foldstart)

        let spaces = ''
        let i = 0
        while i < ind
                let i = i+1
                let spaces = spaces . ' '
        endwhile

        let linestxt = 'lines'
        if lines == 1
                linestxt = 'line'
        endif

        return spaces . '+' . v:folddashes . ' '. lines . ' ' . linestxt . ': ' . getline(v:foldstaendfunction
endfunction


au BufWinEnter,BufRead,BufNewFile * set foldtext=MyFoldText()