fold.txt 24 KB

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