fold.txt 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. *fold.txt* Nvim
  2. VIM REFERENCE MANUAL by Bram Moolenaar
  3. Folding *Folding* *folding* *folds*
  4. You can find an introduction on folding in chapter 28 of the user manual.
  5. |usr_28.txt|
  6. Type |gO| to see the table of contents.
  7. ==============================================================================
  8. 1. Fold methods *fold-methods*
  9. The folding method can be set with the 'foldmethod' option.
  10. When setting 'foldmethod' to a value other than "manual", all folds are
  11. deleted and new ones created. Switching to the "manual" method doesn't remove
  12. the existing folds. This can be used to first define the folds automatically
  13. and then change them manually.
  14. There are six methods to select folds:
  15. manual manually define folds
  16. indent more indent means a higher fold level
  17. expr specify an expression to define folds
  18. syntax folds defined by syntax highlighting
  19. diff folds for unchanged text
  20. marker folds defined by markers in the text
  21. MANUAL *fold-manual*
  22. Use commands to manually define the fold regions. This can also be used by a
  23. script that parses text to find folds.
  24. The level of a fold is only defined by its nesting. To increase the fold
  25. level of a fold for a range of lines, define a fold inside it that has the
  26. same lines.
  27. The manual folds are lost when you abandon the file. To save the folds use
  28. the |:mkview| command. The view can be restored later with |:loadview|.
  29. INDENT *fold-indent*
  30. The folds are automatically defined by the indent of the lines.
  31. The foldlevel is computed from the indent of the line, divided by the
  32. 'shiftwidth' (rounded down). A sequence of lines with the same or higher fold
  33. level form a fold, with the lines with a higher level forming a nested fold.
  34. The nesting of folds is limited with 'foldnestmax'.
  35. Some lines are ignored and get the fold level of the line above or below it,
  36. whichever is lower. These are empty or white lines and lines starting
  37. with a character in 'foldignore'. White space is skipped before checking for
  38. characters in 'foldignore'. For C use "#" to ignore preprocessor lines.
  39. When you want to ignore lines in another way, use the "expr" method. The
  40. |indent()| function can be used in 'foldexpr' to get the indent of a line.
  41. EXPR *fold-expr*
  42. The folds are automatically defined by their foldlevel, like with the "indent"
  43. method. The value of the 'foldexpr' option is evaluated to get the foldlevel
  44. of a line. Examples:
  45. This will create a fold for all consecutive lines that start with a tab: >
  46. :set foldexpr=getline(v:lnum)[0]==\"\\t\"
  47. This will make a fold out of paragraphs separated by blank lines: >
  48. :set foldexpr=getline(v:lnum)=~'^\\s*$'&&getline(v:lnum+1)=~'\\S'?'<1':1
  49. This does the same: >
  50. :set foldexpr=getline(v:lnum-1)=~'^\\s*$'&&getline(v:lnum)=~'\\S'?'>1':1
  51. Note that backslashes must be used to escape characters that ":set" handles
  52. differently (space, backslash, double quote, etc., see |option-backslash|).
  53. The most efficient is to call a function without arguments: >
  54. :set foldexpr=MyFoldLevel()
  55. The function must use v:lnum. See |expr-option-function|.
  56. These are the conditions with which the expression is evaluated:
  57. - The current buffer and window are set for the line.
  58. - The variable "v:lnum" is set to the line number.
  59. The result of foldexpr then determines the fold level as follows:
  60. value meaning ~
  61. 0 the line is not in a fold
  62. 1, 2, .. the line is in a fold with this level
  63. -1 the fold level is undefined, use the fold level of a
  64. line before or after this line, whichever is the
  65. lowest.
  66. "=" use fold level from the previous line
  67. "a1", "a2", .. add one, two, .. to the fold level of the previous
  68. line, use the result for the current line
  69. "s1", "s2", .. subtract one, two, .. from the fold level of the
  70. previous line, use the result for the next line
  71. "<1", "<2", .. a fold with this level ends at this line
  72. ">1", ">2", .. a fold with this level starts at this line
  73. The result values "=", "s" and "a" are more expensive, please see
  74. |fold-expr-slow|.
  75. It is not required to mark the start (end) of a fold with ">1" ("<1"), a fold
  76. will also start (end) when the fold level is higher (lower) than the fold
  77. level of the previous line.
  78. There must be no side effects from the expression. The text in the buffer,
  79. cursor position, the search patterns, options etc. must not be changed.
  80. You can change and restore them if you are careful.
  81. If there is some error in the expression, or the resulting value isn't
  82. recognized, there is no error message and the fold level will be zero.
  83. For debugging the 'debug' option can be set to "msg", the error messages will
  84. be visible then.
  85. If the 'foldexpr' expression starts with s: or |<SID>|, then it is replaced
  86. with the script ID (|local-function|). Examples: >
  87. set foldexpr=s:MyFoldExpr()
  88. set foldexpr=<SID>SomeFoldExpr()
  89. <
  90. An example of using "a1" and "s1": For a multi-line C comment, a line
  91. containing "/*" would return "a1" to start a fold, and a line containing "*/"
  92. would return "s1" to end the fold after that line: >
  93. if match(thisline, '/\*') >= 0
  94. return 'a1'
  95. elseif match(thisline, '\*/') >= 0
  96. return 's1'
  97. else
  98. return '='
  99. endif
  100. However, this won't work for single line comments, strings, etc.
  101. |foldlevel()| can be useful to compute a fold level relative to a previous
  102. fold level. But note that foldlevel() may return -1 if the level is not known
  103. yet. And it returns the level at the start of the line, while a fold might
  104. end in that line.
  105. It may happen that folds are not updated properly. You can use |zx| or |zX|
  106. to force updating folds.
  107. MINIMIZING COMPUTATIONAL COST *fold-expr-slow*
  108. Due to its computational cost, this fold method can make Vim unresponsive,
  109. especially when the fold level of all lines have to be initially computed.
  110. Afterwards, after each change, Vim restricts the computation of foldlevels
  111. to those lines whose fold level was affected by it (and reuses the known
  112. foldlevels of all the others).
  113. The fold expression should therefore strive to minimize the number of
  114. dependent lines needed for the computation of a given line: For example, try
  115. to avoid the "=", "a" and "s" return values, because these will require the
  116. evaluation of the fold levels on previous lines until an independent fold
  117. level is found.
  118. If this proves difficult, the next best thing could be to cache all fold
  119. levels in a buffer-local variable (b:foldlevels) that is only updated on
  120. |b:changedtick|:
  121. >vim
  122. func MyFoldFunc()
  123. if b:lasttick == b:changedtick
  124. return b:foldlevels[v:lnum - 1]
  125. endif
  126. let b:lasttick = b:changedtick
  127. let b:foldlevels = []
  128. " compute foldlevels ...
  129. return b:foldlevels[v:lnum - 1]
  130. enddef
  131. set foldexpr=s:MyFoldFunc()
  132. <
  133. In above example further speedup was gained by using a function without
  134. arguments (that must still use v:lnum). See |expr-option-function|.
  135. SYNTAX *fold-syntax*
  136. A fold is defined by syntax items that have the "fold" argument. |:syn-fold|
  137. The fold level is defined by nesting folds. The nesting of folds is limited
  138. with 'foldnestmax'.
  139. Be careful to specify proper syntax syncing. If this is not done right, folds
  140. may differ from the displayed highlighting. This is especially relevant when
  141. using patterns that match more than one line. In case of doubt, try using
  142. brute-force syncing: >
  143. :syn sync fromstart
  144. DIFF *fold-diff*
  145. The folds are automatically defined for text that is not part of a change or
  146. close to a change.
  147. This method only works properly when the 'diff' option is set for the current
  148. window and changes are being displayed. Otherwise the whole buffer will be
  149. one big fold.
  150. The 'diffopt' option can be used to specify the context. That is, the number
  151. of lines between the fold and a change that are not included in the fold. For
  152. example, to use a context of 8 lines: >
  153. :set diffopt=filler,context:8
  154. The default context is six lines.
  155. When 'scrollbind' is also set, Vim will attempt to keep the same folds open in
  156. other diff windows, so that the same text is visible.
  157. MARKER *fold-marker*
  158. Markers in the text tell where folds start and end. This allows you to
  159. precisely specify the folds. This will allow deleting and putting a fold,
  160. without the risk of including the wrong lines. The 'foldtext' option is
  161. normally set such that the text before the marker shows up in the folded line.
  162. This makes it possible to give a name to the fold.
  163. Markers can have a level included, or can use matching pairs. Including a
  164. level is easier, you don't have to add end markers and avoid problems with
  165. non-matching marker pairs. Example: >
  166. /* global variables {{{1 */
  167. int varA, varB;
  168. /* functions {{{1 */
  169. /* funcA() {{{2 */
  170. void funcA() {}
  171. /* funcB() {{{2 */
  172. void funcB() {}
  173. < *{{{* *}}}*
  174. A fold starts at a "{{{" marker. The following number specifies the fold
  175. level. What happens depends on the difference between the current fold level
  176. and the level given by the marker:
  177. 1. If a marker with the same fold level is encountered, the previous fold
  178. ends and another fold with the same level starts.
  179. 2. If a marker with a higher fold level is found, a nested fold is started.
  180. 3. If a marker with a lower fold level is found, all folds up to and including
  181. this level end and a fold with the specified level starts.
  182. The number indicates the fold level. A zero cannot be used (a marker with
  183. level zero is ignored). You can use "}}}" with a digit to indicate the level
  184. of the fold that ends. The fold level of the following line will be one less
  185. than the indicated level. Note that Vim doesn't look back to the level of the
  186. matching marker (that would take too much time). Example: >
  187. {{{1
  188. fold level here is 1
  189. {{{3
  190. fold level here is 3
  191. }}}3
  192. fold level here is 2
  193. You can also use matching pairs of "{{{" and "}}}" markers to define folds.
  194. Each "{{{" increases the fold level by one, each "}}}" decreases the fold
  195. level by one. Be careful to keep the markers matching! Example: >
  196. {{{
  197. fold level here is 1
  198. {{{
  199. fold level here is 2
  200. }}}
  201. fold level here is 1
  202. You can mix using markers with a number and without a number. A useful way of
  203. doing this is to use numbered markers for large folds, and unnumbered markers
  204. locally in a function. For example use level one folds for the sections of
  205. your file like "structure definitions", "local variables" and "functions".
  206. Use level 2 markers for each definition and function, Use unnumbered markers
  207. inside functions. When you make changes in a function to split up folds, you
  208. don't have to renumber the markers.
  209. The markers can be set with the 'foldmarker' option. It is recommended to
  210. keep this at the default value of "{{{,}}}", so that files can be exchanged
  211. between Vim users. Only change it when it is required for the file (e.g., it
  212. contains markers from another folding editor, or the default markers cause
  213. trouble for the language of the file).
  214. *fold-create-marker*
  215. "zf" can be used to create a fold defined by markers. Vim will insert the
  216. markers for you. Vim will append the start and end marker, as specified with
  217. 'foldmarker'. The markers are appended to the end of the line.
  218. 'commentstring' is used if it isn't empty.
  219. This does not work properly when:
  220. - The line already contains a marker with a level number. Vim then doesn't
  221. know what to do.
  222. - Folds nearby use a level number in their marker which gets in the way.
  223. - The line is inside a comment, 'commentstring' isn't empty and nested
  224. comments don't work. For example with C: adding `/* {{{ */` inside a comment
  225. will truncate the existing comment. Either put the marker before or after
  226. the comment, or add the marker manually.
  227. Generally it's not a good idea to let Vim create markers when you already have
  228. markers with a level number.
  229. *fold-delete-marker*
  230. "zd" can be used to delete a fold defined by markers. Vim will delete the
  231. markers for you. Vim will search for the start and end markers, as specified
  232. with 'foldmarker', at the start and end of the fold. When the text around the
  233. marker matches with 'commentstring', that text is deleted as well.
  234. This does not work properly when:
  235. - A line contains more than one marker and one of them specifies a level.
  236. Only the first one is removed, without checking if this will have the
  237. desired effect of deleting the fold.
  238. - The marker contains a level number and is used to start or end several folds
  239. at the same time.
  240. ==============================================================================
  241. 2. Fold commands *fold-commands* *E490*
  242. All folding commands start with "z". Hint: the "z" looks like a folded piece
  243. of paper, if you look at it from the side.
  244. CREATING AND DELETING FOLDS ~
  245. *zf* *E350*
  246. zf{motion} or
  247. {Visual}zf Operator to create a fold.
  248. This only works when 'foldmethod' is "manual" or "marker".
  249. The new fold will be closed for the "manual" method.
  250. 'foldenable' will be set.
  251. Also see |fold-create-marker|.
  252. *zF*
  253. zF Create a fold for [count] lines. Works like "zf".
  254. :{range}fo[ld] *:fold* *:fo*
  255. Create a fold for the lines in {range}. Works like "zf".
  256. *zd* *E351*
  257. zd Delete one fold at the cursor. When the cursor is on a folded
  258. line, that fold is deleted. Nested folds are moved one level
  259. up. In Visual mode one level of all folds (partially) in the
  260. selected area are deleted.
  261. Careful: This easily deletes more folds than you expect and
  262. there is no undo for manual folding.
  263. This only works when 'foldmethod' is "manual" or "marker".
  264. Also see |fold-delete-marker|.
  265. *zD*
  266. zD Delete folds recursively at the cursor. In Visual mode all
  267. folds (partially) in the selected area and all nested folds in
  268. them are deleted.
  269. This only works when 'foldmethod' is "manual" or "marker".
  270. Also see |fold-delete-marker|.
  271. *zE* *E352*
  272. zE Eliminate all folds in the window.
  273. This only works when 'foldmethod' is "manual" or "marker".
  274. Also see |fold-delete-marker|.
  275. OPENING AND CLOSING FOLDS ~
  276. A fold smaller than 'foldminlines' will always be displayed like it was open.
  277. Therefore the commands below may work differently on small folds.
  278. *zo*
  279. zo Open one fold under the cursor. When a count is given, that
  280. many folds deep will be opened. In Visual mode one level of
  281. folds is opened for all lines in the selected area.
  282. *zO*
  283. zO Open all folds under the cursor recursively. Folds that don't
  284. contain the cursor line are unchanged.
  285. In Visual mode it opens all folds that are in the selected
  286. area, also those that are only partly selected.
  287. *zc*
  288. zc Close one fold under the cursor. When a count is given, that
  289. many folds deep are closed. In Visual mode one level of folds
  290. is closed for all lines in the selected area.
  291. 'foldenable' will be set.
  292. *zC*
  293. zC Close all folds under the cursor recursively. Folds that
  294. don't contain the cursor line are unchanged.
  295. In Visual mode it closes all folds that are in the selected
  296. area, also those that are only partly selected.
  297. 'foldenable' will be set.
  298. *za*
  299. za Summary: Toggle the fold under the cursor.
  300. When on a closed fold: open it. When folds are nested, you
  301. may have to use "za" several times. When a count is given,
  302. that many closed folds are opened.
  303. When on an open fold: close it and set 'foldenable'. This
  304. will only close one level, since using "za" again will open
  305. the fold. When a count is given that many folds will be
  306. closed (that's not the same as repeating "za" that many
  307. times).
  308. *zA*
  309. zA When on a closed fold: open it recursively.
  310. When on an open fold: close it recursively and set
  311. 'foldenable'.
  312. *zv*
  313. zv View cursor line: Open just enough folds to make the line in
  314. which the cursor is located not folded.
  315. *zx*
  316. zx Update folds: Undo manually opened and closed folds: re-apply
  317. 'foldlevel', then do "zv": View cursor line.
  318. Also forces recomputing folds. This is useful when using
  319. 'foldexpr' and the buffer is changed in a way that results in
  320. folds not to be updated properly.
  321. *zX*
  322. zX Undo manually opened and closed folds: re-apply 'foldlevel'.
  323. Also forces recomputing folds, like |zx|.
  324. *zm*
  325. zm Fold more: Subtract |v:count1| from 'foldlevel'. If
  326. 'foldlevel' was already zero nothing happens.
  327. 'foldenable' will be set.
  328. *zM*
  329. zM Close all folds: set 'foldlevel' to 0.
  330. 'foldenable' will be set.
  331. *zr*
  332. zr Reduce folding: Add |v:count1| to 'foldlevel'.
  333. *zR*
  334. zR Open all folds. This sets 'foldlevel' to highest fold level.
  335. *:foldo* *:foldopen*
  336. :{range}foldo[pen][!]
  337. Open folds in {range}. When [!] is added all folds are
  338. opened. Useful to see all the text in {range}. Without [!]
  339. one level of folds is opened.
  340. *:foldc* *:foldclose*
  341. :{range}foldc[lose][!]
  342. Close folds in {range}. When [!] is added all folds are
  343. closed. Useful to hide all the text in {range}. Without [!]
  344. one level of folds is closed.
  345. *zn*
  346. zn Fold none: reset 'foldenable'. All folds will be open.
  347. *zN*
  348. zN Fold normal: set 'foldenable'. All folds will be as they
  349. were before.
  350. *zi*
  351. zi Invert 'foldenable'.
  352. MOVING OVER FOLDS ~
  353. *[z*
  354. [z Move to the start of the current open fold. If already at the
  355. start, move to the start of the fold that contains it. If
  356. there is no containing fold, the command fails.
  357. When a count is used, repeats the command [count] times.
  358. *]z*
  359. ]z Move to the end of the current open fold. If already at the
  360. end, move to the end of the fold that contains it. If there
  361. is no containing fold, the command fails.
  362. When a count is used, repeats the command [count] times.
  363. *zj*
  364. zj Move downwards to the start of the next fold. A closed fold
  365. is counted as one fold.
  366. When a count is used, repeats the command [count] times.
  367. This command can be used after an |operator|.
  368. *zk*
  369. zk Move upwards to the end of the previous fold. A closed fold
  370. is counted as one fold.
  371. When a count is used, repeats the command [count] times.
  372. This command can be used after an |operator|.
  373. EXECUTING COMMANDS ON FOLDS ~
  374. :[range]foldd[oopen] {cmd} *:foldd* *:folddo* *:folddoopen*
  375. Execute {cmd} on all lines that are not in a closed fold.
  376. When [range] is given, only these lines are used.
  377. Each time {cmd} is executed the cursor is positioned on the
  378. line it is executed for.
  379. This works like the ":global" command: First all lines that
  380. are not in a closed fold are marked. Then the {cmd} is
  381. executed for all marked lines. Thus when {cmd} changes the
  382. folds, this has no influence on where it is executed (except
  383. when lines are deleted, of course).
  384. Example: >
  385. :folddoopen s/end/loop_end/ge
  386. < Note the use of the "e" flag to avoid getting an error message
  387. where "end" doesn't match.
  388. :[range]folddoc[losed] {cmd} *:folddoc* *:folddoclosed*
  389. Execute {cmd} on all lines that are in a closed fold.
  390. Otherwise like ":folddoopen".
  391. ==============================================================================
  392. 3. Fold options *fold-options*
  393. COLORS *fold-colors*
  394. The colors of a closed fold are set with the Folded group |hl-Folded|. The
  395. colors of the fold column are set with the FoldColumn group |hl-FoldColumn|.
  396. Example to set the colors: >
  397. :highlight Folded guibg=grey guifg=blue
  398. :highlight FoldColumn guibg=darkgrey guifg=white
  399. FOLDLEVEL *fold-foldlevel*
  400. 'foldlevel' is a number option: The higher the more folded regions are open.
  401. When 'foldlevel' is 0, all folds are closed.
  402. When 'foldlevel' is positive, some folds are closed.
  403. When 'foldlevel' is very high, all folds are open.
  404. 'foldlevel' is applied when it is changed. After that manually folds can be
  405. opened and closed.
  406. When increased, folds above the new level are opened. No manually opened
  407. folds will be closed.
  408. When decreased, folds above the new level are closed. No manually closed
  409. folds will be opened.
  410. FOLDTEXT *fold-foldtext*
  411. 'foldtext' is a string option that specifies an expression. This expression
  412. is evaluated to obtain the text displayed for a closed fold. Example: >
  413. :set foldtext=v:folddashes.substitute(getline(v:foldstart),'/\\*\\\|\\*/\\\|{{{\\d\\=','','g')
  414. This shows the first line of the fold, with "/*", "*/" and "{{{" removed.
  415. Note the use of backslashes to avoid some characters to be interpreted by the
  416. ":set" command. It is much simpler to define a function and call it: >
  417. :set foldtext=MyFoldText()
  418. :function MyFoldText()
  419. : let line = getline(v:foldstart)
  420. : let sub = substitute(line, '/\*\|\*/\|{{{\d\=', '', 'g')
  421. : return v:folddashes .. sub
  422. :endfunction
  423. Evaluating 'foldtext' is done in the |sandbox|. The current window is set to
  424. the window that displays the line.
  425. Errors are ignored. For debugging set the 'debug' option to "throw".
  426. The default value is |foldtext()|. This returns a reasonable text for most
  427. types of folding. If you don't like it, you can specify your own 'foldtext'
  428. expression. It can use these special Vim variables:
  429. v:foldstart line number of first line in the fold
  430. v:foldend line number of last line in the fold
  431. v:folddashes a string that contains dashes to represent the
  432. foldlevel.
  433. v:foldlevel the foldlevel of the fold
  434. If the result is a |List|, it is parsed and drawn like "overlay" virtual text
  435. (see |nvim_buf_set_extmark()|), otherwise the result is converted to a string
  436. where a TAB is replaced with a space and unprintable characters are made into
  437. printable characters.
  438. The resulting line is truncated to fit in the window, it never wraps.
  439. When there is room after the text, it is filled with the character specified
  440. by 'fillchars'.
  441. If the 'foldtext' expression starts with s: or |<SID>|, then it is replaced
  442. with the script ID (|local-function|). Examples: >
  443. set foldtext=s:MyFoldText()
  444. set foldtext=<SID>SomeFoldText()
  445. <
  446. Note that backslashes need to be used for characters that the ":set" command
  447. handles differently: Space, backslash and double-quote. |option-backslash|
  448. FOLDCOLUMN *fold-foldcolumn*
  449. 'foldcolumn' is a number, which sets the width for a column on the side of the
  450. window to indicate folds. When it is zero, there is no foldcolumn. A normal
  451. value is auto:9. The maximum is 9.
  452. An open fold is indicated with a column that has a '-' at the top and '|'
  453. characters below it. This column stops where the open fold stops. When folds
  454. nest, the nested fold is one character right of the fold it's contained in.
  455. A closed fold is indicated with a '+'.
  456. These characters can be changed with the 'fillchars' option.
  457. Where the fold column is too narrow to display all nested folds, digits are
  458. shown to indicate the nesting level.
  459. The mouse can also be used to open and close folds by clicking in the
  460. fold column:
  461. - Click on a '+' to open the closed fold at this row.
  462. - Click on any other non-blank character to close the open fold at this row.
  463. OTHER OPTIONS
  464. 'foldenable' 'fen': Open all folds while not set.
  465. 'foldexpr' 'fde': Expression used for "expr" folding.
  466. 'foldignore' 'fdi': Characters used for "indent" folding.
  467. 'foldmarker' 'fmr': Defined markers used for "marker" folding.
  468. 'foldmethod' 'fdm': Name of the current folding method.
  469. 'foldminlines' 'fml': Minimum number of screen lines for a fold to be
  470. displayed closed.
  471. 'foldnestmax' 'fdn': Maximum nesting for "indent" and "syntax" folding.
  472. 'foldopen' 'fdo': Which kinds of commands open closed folds.
  473. 'foldclose' 'fcl': When the folds not under the cursor are closed.
  474. ==============================================================================
  475. 4. Behavior of folds *fold-behavior*
  476. When moving the cursor upwards or downwards and when scrolling, the cursor
  477. will move to the first line of a sequence of folded lines. When the cursor is
  478. already on a folded line, it moves to the next unfolded line or the next
  479. closed fold.
  480. While the cursor is on folded lines, the cursor is always displayed in the
  481. first column. The ruler does show the actual cursor position, but since the
  482. line is folded, it cannot be displayed there.
  483. Many movement commands handle a sequence of folded lines like an empty line.
  484. For example, the "w" command stops once in the first column.
  485. When starting a search in a closed fold it will not find a match in the
  486. current fold. It's like a forward search always starts from the end of the
  487. closed fold, while a backwards search starts from the start of the closed
  488. fold.
  489. When in Insert mode, the cursor line is never folded. That allows you to see
  490. what you type!
  491. When using an operator, a closed fold is included as a whole. Thus "dl"
  492. deletes the whole closed fold under the cursor.
  493. For Ex commands that work on buffer lines the range is adjusted to always
  494. start at the first line of a closed fold and end at the last line of a closed
  495. fold. Thus this command: >
  496. :s/foo/bar/g
  497. when used with the cursor on a closed fold, will replace "foo" with "bar" in
  498. all lines of the fold.
  499. This does not happen for |:folddoopen| and |:folddoclosed|.
  500. When editing a buffer that has been edited before, the last used folding
  501. settings are used again. For manual folding the defined folds are restored.
  502. For all folding methods the manually opened and closed folds are restored.
  503. If this buffer has been edited in this window, the values from back then are
  504. used. Otherwise the values from the window where the buffer was edited last
  505. are used.
  506. ==============================================================================
  507. vim:tw=78:ts=8:noet:ft=help:norl: