Как мне временно свернуть мой .vimrc с помощью сворачивания кода vim? (SP13-ВИМ)

450
Prashanth Chandra

Я использую spf13-vim, и я хотел, чтобы мой vimrc складывался в такие разделы, как этот

+------126 lines: Environment {---------------------------------------------------------------------------------------------------------------------------------------------------------------------- 

Я понял, как это сделать, используя visual (vjjjjjjjj ...) и zf / za, но как мне сделать его постоянным, чтобы я мог переключать каждую часть, открывать или закрывать каждый раз, когда открываю файл?

Я попытался использовать маркеры, но, похоже, это не сработало так, как я хочу (в итоге складывается 2-4 строки вместо 124 строк, которые я хочу)

Вот мои настройки сгиба

foldmarker={,} foldlevel=0 foldmethod=marker 
0

1 ответ на вопрос

2
Ingo Karkat

For a single file (like ~/.vimrc), I would configure the folding via a modeline; i.e. a special comment at the end of the file that Vim recognizes and sets the fold-related options accordingly. Note: I wouldn't use {,} as fold markers, as those also occur in Vimscript (to define Dictionary objects); better stick to the original ones:

" vim: set fdm=marker fmr={{{,}}} fdl=0 : 

You would then introduce the folding blocks like this:

" Environment {{{ 

Why your global fold settings don't work, I don't know. It may be caused by spf-13. Vim "distributions" like spf-13 and Janus lure you with a quick install and out-of-the-box settings, but you pay the price with increased complexity (you need to understand both Vim's runtime loading scheme and the arbitrary conventions of the distribution) and inflexibility (the distribution may make some things easier, but other things very difficult). Vim is incredibly customizable, using someone else's customization makes no sense.