annotate runtime/doc/usr_28.txt @ 29542:61b400b5e1a8 v9.0.0112

patch 9.0.0112: MS-Windows: test fails because file already exists Commit: https://github.com/vim/vim/commit/0f823c360947779d9de6048c6bce51c670a06eb6 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jul 30 15:35:12 2022 +0100 patch 9.0.0112: MS-Windows: test fails because file already exists Problem: MS-Windows: test fails because file already exists. Solution: Wait a little while until the file is gone.
author Bram Moolenaar <Bram@vim.org>
date Sat, 30 Jul 2022 16:45:04 +0200
parents f8116058ca76
children 4635e43f2c6f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29314
f8116058ca76 release version 9.0
Bram Moolenaar <Bram@vim.org>
parents: 18879
diff changeset
1 *usr_28.txt* For Vim version 9.0. Last change: 2008 Jun 14
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 VIM USER MANUAL - by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 Folding
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 Structured text can be separated in sections. And sections in sub-sections.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 Folding allows you to display a section as one line, providing an overview.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 This chapter explains the different ways this can be done.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 |28.1| What is folding?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 |28.2| Manual folding
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 |28.3| Working with folds
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 |28.4| Saving and restoring folds
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 |28.5| Folding by indent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 |28.6| Folding with markers
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 |28.7| Folding by syntax
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 |28.8| Folding by expression
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 |28.9| Folding unchanged lines
4119
61bcafd8c648 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2577
diff changeset
21 |28.10| Which fold method to use?
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 Next chapter: |usr_29.txt| Moving through programs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 Previous chapter: |usr_27.txt| Search commands and patterns
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 Table of contents: |usr_toc.txt|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 *28.1* What is folding?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 Folding is used to show a range of lines in the buffer as a single line on the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 screen. Like a piece of paper which is folded to make it shorter:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 +------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 | line 1 |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 | line 2 |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 | line 3 |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 |_______________________ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 \ \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 \________________________\
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 / folded lines /
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 /________________________/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 | line 12 |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 | line 13 |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 | line 14 |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 +------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 The text is still in the buffer, unchanged. Only the way lines are displayed
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 is affected by folding.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 The advantage of folding is that you can get a better overview of the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 structure of text, by folding lines of a section and replacing it with a line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 that indicates that there is a section.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 *28.2* Manual folding
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 Try it out: Position the cursor in a paragraph and type: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 zfap
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 You will see that the paragraph is replaced by a highlighted line. You have
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 created a fold. |zf| is an operator and |ap| a text object selection. You
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 can use the |zf| operator with any movement command to create a fold for the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 text that it moved over. |zf| also works in Visual mode.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 To view the text again, open the fold by typing: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 zo
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 And you can close the fold again with: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 zc
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 All the folding commands start with "z". With some fantasy, this looks like a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 folded piece of paper, seen from the side. The letter after the "z" has a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 mnemonic meaning to make it easier to remember the commands:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 zf F-old creation
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 zo O-pen a fold
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 zc C-lose a fold
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 Folds can be nested: A region of text that contains folds can be folded
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 again. For example, you can fold each paragraph in this section, and then
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 fold all the sections in this chapter. Try it out. You will notice that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 opening the fold for the whole chapter will restore the nested folds as they
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 were, some may be open and some may be closed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 Suppose you have created several folds, and now want to view all the text.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 You could go to each fold and type "zo". To do this faster, use this command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 zr
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 This will R-educe the folding. The opposite is: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 zm
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 This folds M-ore. You can repeat "zr" and "zm" to open and close nested folds
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 of several levels.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 If you have nested several levels deep, you can open all of them with: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 zR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 This R-educes folds until there are none left. And you can close all folds
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 with: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 zM
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 This folds M-ore and M-ore.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 You can quickly disable the folding with the |zn| command. Then |zN| brings
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 back the folding as it was. |zi| toggles between the two. This is a useful
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 way of working:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 - create folds to get overview on your file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 - move around to where you want to do your work
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 - do |zi| to look at the text and edit it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 - do |zi| again to go back to moving around
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 More about manual folding in the reference manual: |fold-manual|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 *28.3* Working with folds
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 When some folds are closed, movement commands like "j" and "k" move over a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 fold like it was a single, empty line. This allows you to quickly move around
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 over folded text.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 You can yank, delete and put folds as if it was a single line. This is very
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 useful if you want to reorder functions in a program. First make sure that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 each fold contains a whole function (or a bit less) by selecting the right
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 'foldmethod'. Then delete the function with "dd", move the cursor and put it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 with "p". If some lines of the function are above or below the fold, you can
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 use Visual selection:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 - put the cursor on the first line to be moved
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 - hit "V" to start Visual mode
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 - put the cursor on the last line to be moved
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 - hit "d" to delete the selected lines.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 - move the cursor to the new position and "p"ut the lines there.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 It is sometimes difficult to see or remember where a fold is located, thus
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 where a |zo| command would actually work. To see the defined folds: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 :set foldcolumn=4
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 This will show a small column on the left of the window to indicate folds.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 A "+" is shown for a closed fold. A "-" is shown at the start of each open
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 fold and "|" at following lines of the fold.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 You can use the mouse to open a fold by clicking on the "+" in the foldcolumn.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 Clicking on the "-" or a "|" below it will close an open fold.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 To open all folds at the cursor line use |zO|.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 To close all folds at the cursor line use |zC|.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 To delete a fold at the cursor line use |zd|.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 To delete all folds at the cursor line use |zD|.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 When in Insert mode, the fold at the cursor line is never closed. That allows
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 you to see what you type!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 Folds are opened automatically when jumping around or moving the cursor left
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 or right. For example, the "0" command opens the fold under the cursor
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 (if 'foldopen' contains "hor", which is the default). The 'foldopen' option
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 can be changed to open folds for specific commands. If you want the line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 under the cursor always to be open, do this: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 :set foldopen=all
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 Warning: You won't be able to move onto a closed fold then. You might want to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 use this only temporarily and then set it back to the default: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 :set foldopen&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 You can make folds close automatically when you move out of it: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 :set foldclose=all
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 This will re-apply 'foldlevel' to all folds that don't contain the cursor.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 You have to try it out if you like how this feels. Use |zm| to fold more and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 |zr| to fold less (reduce folds).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 The folding is local to the window. This allows you to open two windows on
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 the same buffer, one with folds and one without folds. Or one with all folds
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 closed and one with all folds open.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 *28.4* Saving and restoring folds
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 When you abandon a file (starting to edit another one), the state of the folds
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 is lost. If you come back to the same file later, all manually opened and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 closed folds are back to their default. When folds have been created
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 manually, all folds are gone! To save the folds use the |:mkview| command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 :mkview
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 This will store the settings and other things that influence the view on the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 file. You can change what is stored with the 'viewoptions' option.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 When you come back to the same file later, you can load the view again: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 :loadview
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 You can store up to ten views on one file. For example, to save the current
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 setup as the third view and load the second view: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 :mkview 3
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 :loadview 2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 Note that when you insert or delete lines the views might become invalid.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 Also check out the 'viewdir' option, which specifies where the views are
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 stored. You might want to delete old views now and then.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 *28.5* Folding by indent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 Defining folds with |zf| is a lot of work. If your text is structured by
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 giving lower level items a larger indent, you can use the indent folding
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 method. This will create folds for every sequence of lines with the same
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 indent. Lines with a larger indent will become nested folds. This works well
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 with many programming languages.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 Try this by setting the 'foldmethod' option: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 :set foldmethod=indent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 Then you can use the |zm| and |zr| commands to fold more and reduce folding.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 It's easy to see on this example text:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 This line is not indented
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 This line is indented once
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 This line is indented twice
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 This line is indented twice
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 This line is indented once
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 This line is not indented
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 This line is indented once
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 This line is indented once
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 Note that the relation between the amount of indent and the fold depth depends
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 on the 'shiftwidth' option. Each 'shiftwidth' worth of indent adds one to the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 depth of the fold. This is called a fold level.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 When you use the |zr| and |zm| commands you actually increase or decrease the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 'foldlevel' option. You could also set it directly: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 :set foldlevel=3
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 This means that all folds with three times a 'shiftwidth' indent or more will
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 be closed. The lower the foldlevel, the more folds will be closed. When
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 'foldlevel' is zero, all folds are closed. |zM| does set 'foldlevel' to zero.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 The opposite command |zR| sets 'foldlevel' to the deepest fold level that is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 present in the file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 Thus there are two ways to open and close the folds:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 (A) By setting the fold level.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 This gives a very quick way of "zooming out" to view the structure of the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 text, move the cursor, and "zoom in" on the text again.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 (B) By using |zo| and |zc| commands to open or close specific folds.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 This allows opening only those folds that you want to be open, while other
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 folds remain closed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 This can be combined: You can first close most folds by using |zm| a few times
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 and then open a specific fold with |zo|. Or open all folds with |zR| and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 then close specific folds with |zc|.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 But you cannot manually define folds when 'foldmethod' is "indent", as that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 would conflict with the relation between the indent and the fold level.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267 More about folding by indent in the reference manual: |fold-indent|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270 *28.6* Folding with markers
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 Markers in the text are used to specify the start and end of a fold region.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 This gives precise control over which lines are included in a fold. The
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 disadvantage is that the text needs to be modified.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276 Try it: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278 :set foldmethod=marker
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 Example text, as it could appear in a C program:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 /* foobar () {{{ */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283 int foobar()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 /* return a value {{{ */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286 return 42;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 /* }}} */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 /* }}} */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291 Notice that the folded line will display the text before the marker. This is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 very useful to tell what the fold contains.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294 It's quite annoying when the markers don't pair up correctly after moving some
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295 lines around. This can be avoided by using numbered markers. Example:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297 /* global variables {{{1 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298 int varA, varB;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300 /* functions {{{1 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301 /* funcA() {{{2 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302 void funcA() {}
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 /* funcB() {{{2 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305 void funcB() {}
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306 /* }}}1 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308 At every numbered marker a fold at the specified level begins. This will make
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309 any fold at a higher level stop here. You can just use numbered start markers
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310 to define all folds. Only when you want to explicitly stop a fold before
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
311 another starts you need to add an end marker.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313 More about folding with markers in the reference manual: |fold-marker|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 *28.7* Folding by syntax
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318 For each language Vim uses a different syntax file. This defines the colors
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
319 for various items in the file. If you are reading this in Vim, in a terminal
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320 that supports colors, the colors you see are made with the "help" syntax file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321 In the syntax files it is possible to add syntax items that have the "fold"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322 argument. These define a fold region. This requires writing a syntax file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323 and adding these items in it. That's not so easy to do. But once it's done,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 all folding happens automatically.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325 Here we'll assume you are using an existing syntax file. Then there is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326 nothing more to explain. You can open and close folds as explained above.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327 The folds will be created and deleted automatically when you edit the file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329 More about folding by syntax in the reference manual: |fold-syntax|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332 *28.8* Folding by expression
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334 This is similar to folding by indent, but instead of using the indent of a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335 line a user function is called to compute the fold level of a line. You can
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336 use this for text where something in the text indicates which lines belong
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 together. An example is an e-mail message where the quoted text is indicated
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338 by a ">" before the line. To fold these quotes use this: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340 :set foldmethod=expr
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
341 :set foldexpr=strlen(substitute(substitute(getline(v:lnum),'\\s','',\"g\"),'[^>].*','',''))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343 You can try it out on this text:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345 > quoted text he wrote
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346 > quoted text he wrote
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347 > > double quoted text I wrote
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 > > double quoted text I wrote
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 Explanation for the 'foldexpr' used in the example (inside out):
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 getline(v:lnum) gets the current line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 substitute(...,'\\s','','g') removes all white space from the line
237
73354c21f1e4 updated for version 7.0066
vimboss
parents: 7
diff changeset
353 substitute(...,'[^>].*','','') removes everything after leading '>'s
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 strlen(...) counts the length of the string, which
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 is the number of '>'s found
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 Note that a backslash must be inserted before every space, double quote and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 backslash for the ":set" command. If this confuses you, do >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 :set foldexpr
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362 to check the actual resulting value. To correct a complicated expression, use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363 the command-line completion: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 :set foldexpr=<Tab>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 Where <Tab> is a real Tab. Vim will fill in the previous value, which you can
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 then edit.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370 When the expression gets more complicated you should put it in a function and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371 set 'foldexpr' to call that function.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 More about folding by expression in the reference manual: |fold-expr|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 *28.9* Folding unchanged lines
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378 This is useful when you set the 'diff' option in the same window. The
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379 |vimdiff| command does this for you. Example: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380
1622
149d8b46404c updated for version 7.2a
vimboss
parents: 1268
diff changeset
381 :setlocal diff foldmethod=diff scrollbind nowrap foldlevel=1
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383 Do this in every window that shows a different version of the same file. You
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384 will clearly see the differences between the files, while the text that didn't
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385 change is folded.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387 For more details see |fold-diff|.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 *28.10* Which fold method to use?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391
2283
7e1bd501306d Mainly documentation updates.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
392 All these possibilities make you wonder which method you should choose.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393 Unfortunately, there is no golden rule. Here are some hints.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 If there is a syntax file with folding for the language you are editing, that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 is probably the best choice. If there isn't one, you might try to write it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397 This requires a good knowledge of search patterns. It's not easy, but when
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 it's working you will not have to define folds manually.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 Typing commands to manually fold regions can be used for unstructured text.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401 Then use the |:mkview| command to save and restore your folds.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403 The marker method requires you to change the file. If you are sharing the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 files with other people or you have to meet company standards, you might not
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 be allowed to add them.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406 The main advantage of markers is that you can put them exactly where you
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407 want them. That avoids that a few lines are missed when you cut and paste
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408 folds. And you can add a comment about what is contained in the fold.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410 Folding by indent is something that works in many files, but not always very
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411 well. Use it when you can't use one of the other methods. However, it is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
412 very useful for outlining. Then you specifically use one 'shiftwidth' for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
413 each nesting level.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
414
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
415 Folding with expressions can make folds in almost any structured text. It is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
416 quite simple to specify, especially if the start and end of a fold can easily
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
417 be recognized.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
418 If you use the "expr" method to define folds, but they are not exactly how
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
419 you want them, you could switch to the "manual" method. This will not remove
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
420 the defined folds. Then you can delete or add folds manually.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
421
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
422 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
423
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424 Next chapter: |usr_29.txt| Moving through programs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425
14519
5c5908e81e93 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13963
diff changeset
426 Copyright: see |manual-copyright| vim:tw=78:ts=8:noet:ft=help:norl: