annotate runtime/doc/indent.txt @ 1264:f0f817a7d773

updated for version 7.1
author vimboss
date Sat, 12 May 2007 14:32:25 +0000
parents ac4972c657bd
children 73fe8baea242
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1247
ac4972c657bd updated for version 7.1
vimboss
parents: 1201
diff changeset
1 *indent.txt* For Vim version 7.1. Last change: 2007 May 11
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 VIM REFERENCE MANUAL by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 This file is about indenting C programs and other files.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 1. Indenting C programs |C-indenting|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 2. Indenting by expression |indent-expression|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 1. Indenting C programs *C-indenting*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 The basics for C indenting are explained in section |30.2| of the user manual.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 Vim has options for automatically indenting C program files. These options
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 affect only the indent and do not perform other formatting. For comment
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 formatting, see |format-comments|.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 Note that this will not work when the |+smartindent| or |+cindent| features
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 have been disabled at compile time.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 There are in fact four methods available for indentation:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 'autoindent' uses the indent from the previous line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 'smartindent' is like 'autoindent' but also recognizes some C syntax to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 increase/reduce the indent where appropriate.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 'cindent' Works more cleverly than the other two and is configurable to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 different indenting styles.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 'indentexpr' The most flexible of all: Evaluates an expression to compute
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 the indent of a line. When non-empty this method overrides
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 the other ones. See |indent-expression|.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 The rest of this section describes the 'cindent' option.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 Note that 'cindent' indenting does not work for every code scenario. Vim
829
dc8197342755 updated for version 7.0d04
vimboss
parents: 825
diff changeset
36 is not a C compiler: it does not recognize all syntax. One requirement is
dc8197342755 updated for version 7.0d04
vimboss
parents: 825
diff changeset
37 that toplevel functions have a '{' in the first column. Otherwise they are
dc8197342755 updated for version 7.0d04
vimboss
parents: 825
diff changeset
38 easily confused with declarations.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 These four options control C program indenting:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 'cindent' Enables Vim to perform C program indenting automatically.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 'cinkeys' Specifies which keys trigger reindenting in insert mode.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 'cinoptions' Sets your preferred indent style.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 'cinwords' Defines keywords that start an extra indent in the next line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 If 'lisp' is not on and 'equalprg' is empty, the "=" operator indents using
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 Vim's built-in algorithm rather than calling an external program.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 See |autocommand| for how to set the 'cindent' option automatically for C code
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 files and reset it for others.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 *cinkeys-format* *indentkeys-format*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 The 'cinkeys' option is a string that controls Vim's indenting in response to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 typing certain characters or commands in certain contexts. Note that this not
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 only triggers C-indenting. When 'indentexpr' is not empty 'indentkeys' is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 used instead. The format of 'cinkeys' and 'indentkeys' is equal.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 The default is "0{,0},0),:,0#,!^F,o,O,e" which specifies that indenting occurs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 as follows:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 "0{" if you type '{' as the first character in a line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 "0}" if you type '}' as the first character in a line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 "0)" if you type ')' as the first character in a line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 ":" if you type ':' after a label or case statement
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 "0#" if you type '#' as the first character in a line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 "!^F" if you type CTRL-F (which is not inserted)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 "o" if you type a <CR> anywhere or use the "o" command (not in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 insert mode!)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 "O" if you use the "O" command (not in insert mode!)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 "e" if you type the second 'e' for an "else" at the start of a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72
818
1f929f3ca806 updated for version 7.0c03
vimboss
parents: 810
diff changeset
73 Characters that can precede each key: *i_CTRL-F*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 ! When a '!' precedes the key, Vim will not insert the key but will
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 instead reindent the current line. This allows you to define a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 command key for reindenting the current line. CTRL-F is the default
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 key for this. Be careful if you define CTRL-I for this because CTRL-I
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 is the ASCII code for <Tab>.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 * When a '*' precedes the key, Vim will reindent the line before
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 inserting the key. If 'cinkeys' contains "*<Return>", Vim reindents
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 the current line before opening a new line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 0 When a zero precedes the key (but appears after '!' or '*') Vim will
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 reindent the line only if the key is the first character you type in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 the line. When used before "=" Vim will only reindent the line if
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 there is only white space before the word.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 When neither '!' nor '*' precedes the key, Vim reindents the line after you
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 type the key. So ';' sets the indentation of a line which includes the ';'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 Special key names:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 <> Angle brackets mean spelled-out names of keys. For example: "<Up>",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 "<Ins>" (see |key-notation|).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 ^ Letters preceded by a caret (^) are control characters. For example:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 "^F" is CTRL-F.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 o Reindent a line when you use the "o" command or when Vim opens a new
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 line below the current one (e.g., when you type <Enter> in insert
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 mode).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 O Reindent a line when you use the "O" command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 e Reindent a line that starts with "else" when you type the second 'e'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 : Reindent a line when a ':' is typed which is after a label or case
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 statement. Don't reindent for a ":" in "class::method" for C++. To
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 Reindent for any ":", use "<:>".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 =word Reindent when typing the last character of "word". "word" may
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 actually be part of another word. Thus "=end" would cause reindenting
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 when typing the "d" in "endif" or "endwhile". But not when typing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 "bend". Also reindent when completion produces a word that starts
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 with "word". "0=word" reindents when there is only white space before
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 the word.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 =~word Like =word, but ignore case.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 If you really want to reindent when you type 'o', 'O', 'e', '0', '<', '>',
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 '*', ':' or '!', use "<o>", "<O>", "<e>", "<0>", "<<>", "<>>", "<*>", "<:>" or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 "<!>", respectively, for those keys.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 For an emacs-style indent mode where lines aren't indented every time you
1247
ac4972c657bd updated for version 7.1
vimboss
parents: 1201
diff changeset
116 press <Enter> but only if you press <Tab>, I suggest:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 :set cinkeys=0{,0},:,0#,!<Tab>,!^F
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 You might also want to switch off 'autoindent' then.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 Note: If you change the current line's indentation manually, Vim ignores the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 cindent settings for that line. This prevents vim from reindenting after you
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 have changed the indent by typing <BS>, <Tab>, or <Space> in the indent or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 used CTRL-T or CTRL-D.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 *cinoptions-values*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 The 'cinoptions' option sets how Vim performs indentation. In the list below,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 "N" represents a number of your choice (the number can be negative). When
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 there is an 's' after the number, Vim multiplies the number by 'shiftwidth':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 "1s" is 'shiftwidth', "2s" is two times 'shiftwidth', etc. You can use a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 decimal point, too: "-0.5s" is minus half a 'shiftwidth'. The examples below
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 assume a 'shiftwidth' of 4.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 >N Amount added for "normal" indent. Used after a line that should
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 increase the indent (lines starting with "if", an opening brace,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 etc.). (default 'shiftwidth').
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 cino= cino=>2 cino=>2s >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 if (cond) if (cond) if (cond)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 { { {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 foo; foo; foo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 } } }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 eN Add N to the prevailing indent inside a set of braces if the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 opening brace at the End of the line (more precise: is not the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 first character in a line). This is useful if you want a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 different indent when the '{' is at the start of the line from
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 when '{' is at the end of the line. (default 0).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 cino= cino=e2 cino=e-2 >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 if (cond) { if (cond) { if (cond) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 foo; foo; foo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 } } }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 else else else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 { { {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 bar; bar; bar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 } } }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 nN Add N to the prevailing indent for a statement after an "if",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 "while", etc., if it is NOT inside a set of braces. This is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 useful if you want a different indent when there is no '{'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 before the statement from when there is a '{' before it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 (default 0).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 cino= cino=n2 cino=n-2 >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 if (cond) if (cond) if (cond)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 foo; foo; foo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 else else else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 { { {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 bar; bar; bar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 } } }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 fN Place the first opening brace of a function or other block in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 column N. This applies only for an opening brace that is not
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 inside other braces and is at the start of the line. What comes
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 after the brace is put relative to this brace. (default 0).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 cino= cino=f.5s cino=f1s >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 func() func() func()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 { { {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 int foo; int foo; int foo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 {N Place opening braces N characters from the prevailing indent.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 This applies only for opening braces that are inside other
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 braces. (default 0).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 cino= cino={.5s cino={1s >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 if (cond) if (cond) if (cond)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 { { {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 foo; foo; foo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 }N Place closing braces N characters from the matching opening
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 brace. (default 0).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 cino= cino={2,}-0.5s cino=}2 >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 if (cond) if (cond) if (cond)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 { { {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 foo; foo; foo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 } } }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 ^N Add N to the prevailing indent inside a set of braces if the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 opening brace is in column 0. This can specify a different
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 indent for whole of a function (some may like to set it to a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 negative number). (default 0).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 cino= cino=^-2 cino=^-s >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 func() func() func()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 { { {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 if (cond) if (cond) if (cond)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 { { {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 a = b; a = b; a = b;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 } } }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 } } }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 :N Place case labels N characters from the indent of the switch().
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 (default 'shiftwidth').
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 cino= cino=:0 >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 switch (x) switch(x)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 { {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 case 1: case 1:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 a = b; a = b;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 default: default:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 } }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 =N Place statements occurring after a case label N characters from
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 the indent of the label. (default 'shiftwidth').
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 cino= cino==10 >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 case 11: case 11: a = a + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 a = a + 1; b = b + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 lN If N != 0 Vim will align with a case label instead of the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 statement after it in the same line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 cino= cino=l1 >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 switch (a) { switch (a) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 case 1: { case 1: {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 break; break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 } }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 bN If N != 0 Vim will align a final "break" with the case label,
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 170
diff changeset
242 so that case..break looks like a sort of block. (default: 0).
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 cino= cino=b1 >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 switch (x) switch(x)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 { {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 case 1: case 1:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 a = b; a = b;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 break; break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 default: default:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 a = 0; a = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 break; break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 } }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 gN Place C++ scope declarations N characters from the indent of the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 block they are in. (default 'shiftwidth'). A scope declaration
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 can be "public:", "protected:" or "private:".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 cino= cino=g0 >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 { {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 public: public:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 a = b; a = b;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 private: private:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 } }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267 hN Place statements occurring after a C++ scope declaration N
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 characters from the indent of the label. (default
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269 'shiftwidth').
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 cino= cino=h10 >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 public: public: a = a + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 a = a + 1; b = b + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275 pN Parameter declarations for K&R-style function declarations will
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276 be indented N characters from the margin. (default
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277 'shiftwidth').
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 cino= cino=p0 cino=p2s >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 func(a, b) func(a, b) func(a, b)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281 int a; int a; int a;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 char b; char b; char b;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 tN Indent a function return type declaration N characters from the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 margin. (default 'shiftwidth').
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 cino= cino=t0 cino=t7 >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288 int int int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 func() func() func()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290 <
843
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
291 iN Indent C++ base class declarations and constructor
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 initializations, if they start in a new line (otherwise they
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293 are aligned at the right side of the ':').
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294 (default 'shiftwidth').
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296 cino= cino=i0 >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297 class MyClass : class MyClass :
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298 public BaseClass public BaseClass
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299 {} {}
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300 MyClass::MyClass() : MyClass::MyClass() :
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301 BaseClass(3) BaseClass(3)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302 {} {}
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 +N Indent a continuation line (a line that spills onto the next) N
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305 additional characters. (default 'shiftwidth').
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307 cino= cino=+10 >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308 a = b + 9 * a = b + 9 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309 c; c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
311 cN Indent comment lines after the comment opener, when there is no
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312 other text with which to align, N characters from the comment
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313 opener. (default 3). See also |format-comments|.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315 cino= cino=c5 >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 /* /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317 text. text.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318 */ */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
319 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320 CN When N is non-zero, indent comment lines by the amount specified
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321 with the c flag above even if there is other text behind the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322 comment opener. (default 0).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 cino=c0 cino=c0,C1 >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325 /******** /********
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326 text. text.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327 ********/ ********/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328 < (Example uses ":set comments& comments-=s1:/* comments^=s0:/*")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 170
diff changeset
330 /N Indent comment lines N characters extra. (default 0).
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331 cino= cino=/4 >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332 a = b; a = b;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333 /* comment */ /* comment */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334 c = d; c = d;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336 (N When in unclosed parentheses, indent N characters from the line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 with the unclosed parentheses. Add a 'shiftwidth' for every
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338 unclosed parentheses. When N is 0 or the unclosed parentheses
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339 is the first non-white character in its line, line up with the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340 next non-white character after the unclosed parentheses.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
341 (default 'shiftwidth' * 2).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343 cino= cino=(0 >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344 if (c1 && (c2 || if (c1 && (c2 ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345 c3)) c3))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346 foo; foo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347 if (c1 && if (c1 &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 (c2 || c3)) (c2 || c3))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 { {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 uN Same as (N, but for one level deeper. (default 'shiftwidth').
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 cino= cino=u2 >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 if (c123456789 if (c123456789
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 && (c22345 && (c22345
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356 || c3)) || c3))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 UN When N is non-zero, do not ignore the indenting specified by
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 ( or u in case that the unclosed parentheses is the first
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 non-white character in its line. (default 0).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362 cino= or cino=(s cino=(s,U1 >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363 c = c1 && c = c1 &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364 ( (
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 c2 || c2 ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 c3 c3
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 ) && c4; ) && c4;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369 wN When in unclosed parentheses and N is non-zero and either
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370 using "(0" or "u0", respectively, or using "U0" and the unclosed
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371 parentheses is the first non-white character in its line, line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372 up with the character immediately after the unclosed parentheses
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 rather than the first non-white character. (default 0).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375 cino=(0 cino=(0,w1 >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 if ( c1 if ( c1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 && ( c2 && ( c2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378 || c3)) || c3))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379 foo; foo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381 WN When in unclosed parentheses and N is non-zero and either
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382 using "(0" or "u0", respectively and the unclosed parentheses is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383 the last non-white character in its line and it is not the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384 closing parentheses, indent the following line N characters
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385 relative to the outer context (i.e. start of the line or the
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 170
diff changeset
386 next unclosed parentheses). (default: 0).
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388 cino=(0 cino=(0,W4 >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389 a_long_line( a_long_line(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 argument, argument,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391 argument); argument);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 a_short_line(argument, a_short_line(argument,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393 argument); argument);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 mN When N is non-zero, line up a line starting with a closing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 parentheses with the first character of the line with the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397 matching opening parentheses. (default 0).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399 cino=(s cino=(s,m1 >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 c = c1 && ( c = c1 && (
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401 c2 || c2 ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402 c3 c3
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403 ) && c4; ) && c4;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 if ( if (
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 c1 && c2 c1 && c2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406 ) )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407 foo; foo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408 <
829
dc8197342755 updated for version 7.0d04
vimboss
parents: 825
diff changeset
409 MN When N is non-zero, line up a line starting with a closing
dc8197342755 updated for version 7.0d04
vimboss
parents: 825
diff changeset
410 parentheses with the first character of the previous line.
dc8197342755 updated for version 7.0d04
vimboss
parents: 825
diff changeset
411 (default 0).
dc8197342755 updated for version 7.0d04
vimboss
parents: 825
diff changeset
412
dc8197342755 updated for version 7.0d04
vimboss
parents: 825
diff changeset
413 cino= cino=M1 >
dc8197342755 updated for version 7.0d04
vimboss
parents: 825
diff changeset
414 if (cond1 && if (cond1 &&
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
415 cond2 cond2
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
416 ) )
829
dc8197342755 updated for version 7.0d04
vimboss
parents: 825
diff changeset
417 <
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
418 *java-cinoptions* *java-indenting*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
419 jN Indent java anonymous classes correctly. The value 'N' is
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 170
diff changeset
420 currently unused but must be non-zero (e.g. 'j1'). 'j1' will
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
421 indent for example the following code snippet correctly: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
422
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
423 object.add(new ChangeListener() {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424 public void stateChanged(ChangeEvent e) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425 do_something();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
426 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
427 });
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
428 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
429 )N Vim searches for unclosed parentheses at most N lines away.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430 This limits the time needed to search for parentheses. (default
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431 20 lines).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
433 *N Vim searches for unclosed comments at most N lines away. This
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
434 limits the time needed to search for the start of a comment.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
435 (default 30 lines).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
436
1096
83eda510dbc0 updated for version 7.0-222
vimboss
parents: 874
diff changeset
437 #N When N is non-zero recognize shell/Perl comments, starting with
83eda510dbc0 updated for version 7.0-222
vimboss
parents: 874
diff changeset
438 '#'. Default N is zero: don't recognizes '#' comments. Note
83eda510dbc0 updated for version 7.0-222
vimboss
parents: 874
diff changeset
439 that lines starting with # will still be seen as preprocessor
83eda510dbc0 updated for version 7.0-222
vimboss
parents: 874
diff changeset
440 lines.
83eda510dbc0 updated for version 7.0-222
vimboss
parents: 874
diff changeset
441
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
442
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
443 The defaults, spelled out in full, are:
15
631143ac4a01 updated for version 7.0007
vimboss
parents: 7
diff changeset
444 cinoptions=>s,e0,n0,f0,{0,}0,^0,:s,=s,l0,b0,gs,hs,ps,ts,is,+s,c3,C0,
1096
83eda510dbc0 updated for version 7.0-222
vimboss
parents: 874
diff changeset
445 /0,(2s,us,U0,w0,W0,m0,j0,)20,*30,#0
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
446
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
447 Vim puts a line in column 1 if:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
448 - It starts with '#' (preprocessor directives), if 'cinkeys' contains '#'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
449 - It starts with a label (a keyword followed by ':', other than "case" and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
450 "default").
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
451 - Any combination of indentations causes the line to have less than 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
452 indentation.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
453
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
454 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
455 2. Indenting by expression *indent-expression*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
456
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
457 The basics for using flexible indenting are explained in section |30.3| of the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
458 user manual.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
459
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
460 If you want to write your own indent file, it must set the 'indentexpr'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
461 option. Setting the 'indentkeys' option is often useful. See the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
462 $VIMRUNTIME/indent directory for examples.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
464
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
465 REMARKS ABOUT SPECIFIC INDENT FILES ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
466
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
467
501
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 236
diff changeset
468 FORTRAN *ft-fortran-indent*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
469
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 170
diff changeset
470 Block if, select case, and where constructs are indented. Comments, labelled
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
471 statements and continuation lines are indented if the Fortran is in free
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
472 source form, whereas they are not indented if the Fortran is in fixed source
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 170
diff changeset
473 form because of the left margin requirements. Hence manual indent corrections
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
474 will be necessary for labelled statements and continuation lines when fixed
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 170
diff changeset
475 source form is being used. For further discussion of the method used for the
501
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 236
diff changeset
476 detection of source format see |ft-fortran-syntax|.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
477
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
478 Do loops ~
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 170
diff changeset
479 All do loops are left unindented by default. Do loops can be unstructured in
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
480 Fortran with (possibly multiple) loops ending on a labelled executable
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 170
diff changeset
481 statement of almost arbitrary type. Correct indentation requires
4707450c2b33 updated for version 7.0066
vimboss
parents: 170
diff changeset
482 compiler-quality parsing. Old code with do loops ending on labelled statements
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
483 of arbitrary type can be indented with elaborate programs such as Tidy
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 170
diff changeset
484 (http://www.unb.ca/chem/ajit/f_tidy.htm). Structured do/continue loops are
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
485 also left unindented because continue statements are also used for purposes
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 170
diff changeset
486 other than ending a do loop. Programs such as Tidy can convert structured
4707450c2b33 updated for version 7.0066
vimboss
parents: 170
diff changeset
487 do/continue loops to the do/enddo form. Do loops of the do/enddo variety can
4707450c2b33 updated for version 7.0066
vimboss
parents: 170
diff changeset
488 be indented. If you use only structured loops of the do/enddo form, you should
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
489 declare this by setting the fortran_do_enddo variable in your .vimrc as
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
490 follows >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
491
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
492 let fortran_do_enddo=1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
493
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 170
diff changeset
494 in which case do loops will be indented. If all your loops are of do/enddo
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
495 type only in, say, .f90 files, then you should set a buffer flag with an
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
496 autocommand such as >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
497
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
498 au! BufRead,BufNewFile *.f90 let b:fortran_do_enddo=1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
499
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
500 to get do loops indented in .f90 files and left alone in Fortran files with
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
501 other extensions such as .for.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
502
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
503
501
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 236
diff changeset
504 PYTHON *ft-python-indent*
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 22
diff changeset
505
8c60f65311fa updated for version 7.0052
vimboss
parents: 22
diff changeset
506 The amount of indent can be set for the following situations. The examples
8c60f65311fa updated for version 7.0052
vimboss
parents: 22
diff changeset
507 given are de the defaults. Note that the variables are set to an expression,
8c60f65311fa updated for version 7.0052
vimboss
parents: 22
diff changeset
508 so that you can change the value of 'shiftwidth' later.
8c60f65311fa updated for version 7.0052
vimboss
parents: 22
diff changeset
509
8c60f65311fa updated for version 7.0052
vimboss
parents: 22
diff changeset
510 Indent after an open paren: >
8c60f65311fa updated for version 7.0052
vimboss
parents: 22
diff changeset
511 let g:pyindent_open_paren = '&sw * 2'
8c60f65311fa updated for version 7.0052
vimboss
parents: 22
diff changeset
512 Indent after a nested paren: >
8c60f65311fa updated for version 7.0052
vimboss
parents: 22
diff changeset
513 let g:pyindent_nested_paren = '&sw'
8c60f65311fa updated for version 7.0052
vimboss
parents: 22
diff changeset
514 Indent for a continuation line: >
8c60f65311fa updated for version 7.0052
vimboss
parents: 22
diff changeset
515 let g:pyindent_continue = '&sw * 2'
8c60f65311fa updated for version 7.0052
vimboss
parents: 22
diff changeset
516
8c60f65311fa updated for version 7.0052
vimboss
parents: 22
diff changeset
517
1201
4d2585cf5950 updated for version 7.1b
vimboss
parents: 1141
diff changeset
518 SHELL *ft-sh-indent*
4d2585cf5950 updated for version 7.1b
vimboss
parents: 1141
diff changeset
519
4d2585cf5950 updated for version 7.1b
vimboss
parents: 1141
diff changeset
520 The amount of indent applied under various circumstances in a shell file can
4d2585cf5950 updated for version 7.1b
vimboss
parents: 1141
diff changeset
521 be configured by setting the following keys in the |Dictionary|
4d2585cf5950 updated for version 7.1b
vimboss
parents: 1141
diff changeset
522 b:sh_indent_defaults to a specific amount or to a |Funcref| that references a
4d2585cf5950 updated for version 7.1b
vimboss
parents: 1141
diff changeset
523 function that will return the amount desired:
4d2585cf5950 updated for version 7.1b
vimboss
parents: 1141
diff changeset
524
4d2585cf5950 updated for version 7.1b
vimboss
parents: 1141
diff changeset
525 b:sh_indent_options['default'] Default amount of indent.
4d2585cf5950 updated for version 7.1b
vimboss
parents: 1141
diff changeset
526
4d2585cf5950 updated for version 7.1b
vimboss
parents: 1141
diff changeset
527 b:sh_indent_options['continuation-line']
4d2585cf5950 updated for version 7.1b
vimboss
parents: 1141
diff changeset
528 Amount of indent to add to a continued line.
4d2585cf5950 updated for version 7.1b
vimboss
parents: 1141
diff changeset
529
4d2585cf5950 updated for version 7.1b
vimboss
parents: 1141
diff changeset
530 b:sh_indent_options['case-labels']
4d2585cf5950 updated for version 7.1b
vimboss
parents: 1141
diff changeset
531 Amount of indent to add for case labels.
4d2585cf5950 updated for version 7.1b
vimboss
parents: 1141
diff changeset
532
4d2585cf5950 updated for version 7.1b
vimboss
parents: 1141
diff changeset
533 b:sh_indent_options['case-statement']
4d2585cf5950 updated for version 7.1b
vimboss
parents: 1141
diff changeset
534 Amount of indent to add for case statements.
4d2585cf5950 updated for version 7.1b
vimboss
parents: 1141
diff changeset
535
4d2585cf5950 updated for version 7.1b
vimboss
parents: 1141
diff changeset
536 b:sh_indent_options['case-breaks']
4d2585cf5950 updated for version 7.1b
vimboss
parents: 1141
diff changeset
537 Amount of indent to add (or more likely
4d2585cf5950 updated for version 7.1b
vimboss
parents: 1141
diff changeset
538 remove) for case breaks.
4d2585cf5950 updated for version 7.1b
vimboss
parents: 1141
diff changeset
539
501
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 236
diff changeset
540 VERILOG *ft-verilog-indent*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
541
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
542 General block statements such as if, for, case, always, initial, function,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
543 specify and begin, etc., are indented. The module block statements (first
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
544 level blocks) are not indented by default. you can turn on the indent with
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
545 setting a variable in the .vimrc as follows: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
546
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
547 let b:verilog_indent_modules = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
548
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
549 then the module blocks will be indented. To stop this, remove the variable: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
550
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
551 :unlet b:verilog_indent_modules
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
552
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
553 To set the variable only for Verilog file. The following statements can be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
554 used: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
555
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556 au BufReadPost * if exists("b:current_syntax")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
557 au BufReadPost * if b:current_syntax == "verilog"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558 au BufReadPost * let b:verilog_indent_modules = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
559 au BufReadPost * endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
560 au BufReadPost * endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
561
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
562 Furthermore, setting the variable b:verilog_indent_width to change the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
563 indenting width (default is 'shiftwidth'): >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
564
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565 let b:verilog_indent_width = 4
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566 let b:verilog_indent_width = &sw * 2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
567
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568 In addition, you can turn the verbose mode for debug issue: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
569
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570 let b:verilog_indent_verbose = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
571
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
572 Make sure to do ":set cmdheight=2" first to allow the display of the message.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
573
22
cc049b00ee70 updated for version 7.0014
vimboss
parents: 15
diff changeset
574
501
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 236
diff changeset
575 VIM *ft-vim-indent*
22
cc049b00ee70 updated for version 7.0014
vimboss
parents: 15
diff changeset
576
cc049b00ee70 updated for version 7.0014
vimboss
parents: 15
diff changeset
577 For indenting Vim scripts there is one variable that specifies the amount of
cc049b00ee70 updated for version 7.0014
vimboss
parents: 15
diff changeset
578 indent for a continuation line, a line that starts with a backslash: >
cc049b00ee70 updated for version 7.0014
vimboss
parents: 15
diff changeset
579
cc049b00ee70 updated for version 7.0014
vimboss
parents: 15
diff changeset
580 :let g:vim_indent_cont = &sw * 3
cc049b00ee70 updated for version 7.0014
vimboss
parents: 15
diff changeset
581
cc049b00ee70 updated for version 7.0014
vimboss
parents: 15
diff changeset
582 Three times shiftwidth is the default value.
cc049b00ee70 updated for version 7.0014
vimboss
parents: 15
diff changeset
583
cc049b00ee70 updated for version 7.0014
vimboss
parents: 15
diff changeset
584
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585 vim:tw=78:ts=8:ft=help:norl: