我在我的
linux机器上使用vim并且需要代码折叠来为R工作.我安装了Vim-R-plusing2以便能够将代码从vim传递到R会话,但折叠在foldmethod = Syntax时不起作用.如何折叠R工作?
该怎么办:
原文链接:https://www.f2er.com/bash/383348.htmllet r_Syntax_folding = 1
为什么会这样:
此选项可更改Vim-R插件的加载方式.
此代码从Syntax / vim.r复制,并显示上述设置如何更改运行的代码:
" Error if exists("g:r_Syntax_folding") syn region rRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rError,rBraceError,rCurlyError fold syn region rRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rParenError fold syn region rRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rCurlyError,rParenError fold else syn region rRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rCurlyError syn region rRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rParenError syn region rRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rParenError endif
引自帮助
10.8. Fold setup~
Vim has several methods of folding
text (see |fold-methods| and
|fold-commands|). To enable the Syntax
method of folding for R files,put in
your |vimrc|:let r_Syntax_folding = 1
使用上面的选项,Vim将加载R.所有折叠关闭的文件.如果你我更喜欢用all来开始编辑文件折叠打开,放入你的| vimrc |: