blob: 519a3d3b8cafb0fb25df2ce2141999e6d4bbd4b3 [file] [log] [blame]
Bram Moolenaar61da1bf2019-06-06 12:14:49 +02001*sign.txt* For Vim version 8.1. Last change: 2019 Jun 04
Bram Moolenaar071d4272004-06-13 20:20:40 +00002
3
4 VIM REFERENCE MANUAL by Gordon Prieur
5 and Bram Moolenaar
6
7
8Sign Support Features *sign-support*
9
101. Introduction |sign-intro|
112. Commands |sign-commands|
12
Bram Moolenaar071d4272004-06-13 20:20:40 +000013{only available when compiled with the |+signs| feature}
14
15==============================================================================
161. Introduction *sign-intro* *signs*
17
18When a debugger or other IDE tool is driving an editor it needs to be able
19to give specific highlights which quickly tell the user useful information
Bram Moolenaar402d2fe2005-04-15 21:00:38 +000020about the file. One example of this would be a debugger which had an icon
21in the left-hand column denoting a breakpoint. Another example might be an
22arrow representing the Program Counter (PC). The sign features allow both
Bram Moolenaar071d4272004-06-13 20:20:40 +000023placement of a sign, or icon, in the left-hand side of the window and
Bram Moolenaar402d2fe2005-04-15 21:00:38 +000024definition of a highlight which will be applied to that line. Displaying the
Bram Moolenaar071d4272004-06-13 20:20:40 +000025sign as an image is most likely only feasible in gvim (although Sun
Bram Moolenaar402d2fe2005-04-15 21:00:38 +000026Microsystem's dtterm does support this it's the only terminal emulator I know
Bram Moolenaar071d4272004-06-13 20:20:40 +000027of which does). A text sign and the highlight should be feasible in any color
28terminal emulator.
29
Bram Moolenaar402d2fe2005-04-15 21:00:38 +000030Signs and highlights are not useful just for debuggers. Sun's Visual
Bram Moolenaar071d4272004-06-13 20:20:40 +000031WorkShop uses signs and highlights to mark build errors and SourceBrowser
Bram Moolenaar402d2fe2005-04-15 21:00:38 +000032hits. Additionally, the debugger supports 8 to 10 different signs and
Bram Moolenaard09091d2019-01-17 16:07:22 +010033highlight colors, see |NetBeans|.
Bram Moolenaar071d4272004-06-13 20:20:40 +000034
35There are two steps in using signs:
36
371. Define the sign. This specifies the image, text and highlighting. For
38 example, you can define a "break" sign with an image of a stop roadsign and
39 text "!!".
40
412. Place the sign. This specifies the file and line number where the sign is
42 displayed. A defined sign can be placed several times in different lines
43 and files.
44
Bram Moolenaard09091d2019-01-17 16:07:22 +010045 *sign-column*
Bram Moolenaar071d4272004-06-13 20:20:40 +000046When signs are defined for a file, Vim will automatically add a column of two
47characters to display them in. When the last sign is unplaced the column
Bram Moolenaar09521312016-08-12 22:54:35 +020048disappears again. This behavior can be changed with the 'signcolumn' option.
49
50The color of the column is set with the SignColumn group |hl-SignColumn|.
51Example to set the color: >
Bram Moolenaar071d4272004-06-13 20:20:40 +000052
53 :highlight SignColumn guibg=darkgrey
Bram Moolenaar162b7142018-12-21 15:17:36 +010054<
Bram Moolenaarb328cca2019-01-06 16:24:01 +010055 *sign-identifier*
56Each placed sign is identified by a number called the sign identifier. This
57identifier is used to jump to the sign or to remove the sign. The identifier
Bram Moolenaard09091d2019-01-17 16:07:22 +010058is assigned when placing the sign using the |:sign-place| command or the
Bram Moolenaarb328cca2019-01-06 16:24:01 +010059|sign_place()| function. Each sign identifier should be a unique number. If
60multiple placed signs use the same identifier, then jumping to or removing a
61sign becomes unpredictable. To avoid overlapping identifiers, sign groups can
62be used. The |sign_place()| function can be called with a zero sign identifier
63to allocate the next available identifier.
64
Bram Moolenaar162b7142018-12-21 15:17:36 +010065 *sign-group*
Bram Moolenaarb328cca2019-01-06 16:24:01 +010066Each placed sign can be assigned to either the global group or a named group.
67When placing a sign, if a group name is not supplied, or an empty string is
68used, then the sign is placed in the global group. Otherwise the sign is
69placed in the named group. The sign identifier is unique within a group. The
70sign group allows Vim plugins to use unique signs without interfering with
71other plugins using signs.
Bram Moolenaar162b7142018-12-21 15:17:36 +010072
73 *sign-priority*
74Each placed sign is assigned a priority value. When multiple signs are placed
75on the same line, the attributes of the sign with the highest priority is used
76independent of the sign group. The default priority for a sign is 10. The
77priority is assigned at the time of placing a sign.
Bram Moolenaar071d4272004-06-13 20:20:40 +000078
Bram Moolenaard09091d2019-01-17 16:07:22 +010079When the line on which the sign is placed is deleted, the sign is moved to the
80next line (or the last line of the buffer, if there is no next line). When
81the delete is undone the sign does not move back.
82
Bram Moolenaar071d4272004-06-13 20:20:40 +000083==============================================================================
842. Commands *sign-commands* *:sig* *:sign*
85
Bram Moolenaar00a927d2010-05-14 23:24:24 +020086Here is an example that places a sign "piet", displayed with the text ">>", in
Bram Moolenaar071d4272004-06-13 20:20:40 +000087line 23 of the current file: >
88 :sign define piet text=>> texthl=Search
89 :exe ":sign place 2 line=23 name=piet file=" . expand("%:p")
90
91And here is the command to delete it again: >
92 :sign unplace 2
93
94Note that the ":sign" command cannot be followed by another command or a
95comment. If you do need that, use the |:execute| command.
96
97
98DEFINING A SIGN. *:sign-define* *E255* *E160* *E612*
99
Bram Moolenaar162b7142018-12-21 15:17:36 +0100100See |sign_define()| for the equivalent Vim script function.
101
Bram Moolenaar071d4272004-06-13 20:20:40 +0000102:sign define {name} {argument}...
103 Define a new sign or set attributes for an existing sign.
104 The {name} can either be a number (all digits) or a name
Bram Moolenaar4c05fa02019-01-01 15:32:17 +0100105 starting with a non-digit. Leading zeros are ignored, thus
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200106 "0012", "012" and "12" are considered the same name.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000107 About 120 different signs can be defined.
108
109 Accepted arguments:
110
Bram Moolenaar6ee8d892012-01-10 14:55:01 +0100111 icon={bitmap}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000112 Define the file name where the bitmap can be found. Should be
113 a full path. The bitmap should fit in the place of two
114 characters. This is not checked. If the bitmap is too big it
115 will cause redraw problems. Only GTK 2 can scale the bitmap
116 to fit the space available.
117 toolkit supports ~
118 GTK 1 pixmap (.xpm)
119 GTK 2 many
120 Motif pixmap (.xpm)
Bram Moolenaar6ee8d892012-01-10 14:55:01 +0100121 Win32 .bmp, .ico, .cur
122 pixmap (.xpm) |+xpm_w32|
Bram Moolenaar071d4272004-06-13 20:20:40 +0000123
124 linehl={group}
125 Highlighting group used for the whole line the sign is placed
126 in. Most useful is defining a background color.
127
128 text={text} *E239*
129 Define the text that is displayed when there is no icon or the
130 GUI is not being used. Only printable characters are allowed
131 and they must occupy one or two display cells.
132
133 texthl={group}
134 Highlighting group used for the text item.
135
136
137DELETING A SIGN *:sign-undefine* *E155*
138
Bram Moolenaar162b7142018-12-21 15:17:36 +0100139See |sign_undefine()| for the equivalent Vim script function.
140
Bram Moolenaar071d4272004-06-13 20:20:40 +0000141:sign undefine {name}
142 Deletes a previously defined sign. If signs with this {name}
143 are still placed this will cause trouble.
144
145
Bram Moolenaar162b7142018-12-21 15:17:36 +0100146
Bram Moolenaar071d4272004-06-13 20:20:40 +0000147LISTING SIGNS *:sign-list* *E156*
148
Bram Moolenaar162b7142018-12-21 15:17:36 +0100149See |sign_getdefined()| for the equivalent Vim script function.
150
Bram Moolenaar071d4272004-06-13 20:20:40 +0000151:sign list Lists all defined signs and their attributes.
152
153:sign list {name}
154 Lists one defined sign and its attributes.
155
156
157PLACING SIGNS *:sign-place* *E158*
158
Bram Moolenaar162b7142018-12-21 15:17:36 +0100159See |sign_place()| for the equivalent Vim script function.
160
Bram Moolenaar071d4272004-06-13 20:20:40 +0000161:sign place {id} line={lnum} name={name} file={fname}
162 Place sign defined as {name} at line {lnum} in file {fname}.
163 *:sign-fname*
164 The file {fname} must already be loaded in a buffer. The
165 exact file name must be used, wildcards, $ENV and ~ are not
166 expanded, white space must not be escaped. Trailing white
167 space is ignored.
168
169 The sign is remembered under {id}, this can be used for
170 further manipulation. {id} must be a number.
171 It's up to the user to make sure the {id} is used only once in
172 each file (if it's used several times unplacing will also have
173 to be done several times and making changes may not work as
174 expected).
175
Bram Moolenaar162b7142018-12-21 15:17:36 +0100176 The following optional sign attributes can be specified before
177 "file=":
178 group={group} Place sign in sign group {group}
179 priority={prio} Assign priority {prio} to sign
180
181 By default, the sign is placed in the global sign group.
182
183 By default, the sign is assigned a default priority of 10. To
184 assign a different priority value, use "priority={prio}" to
Bram Moolenaar58a7f872019-06-04 22:48:15 +0200185 specify a value. The priority is used to determine the sign
186 that is displayed when multiple signs are placed on the same
187 line.
Bram Moolenaar162b7142018-12-21 15:17:36 +0100188
189 Examples: >
190 :sign place 5 line=3 name=sign1 file=a.py
191 :sign place 6 group=g2 line=2 name=sign2 file=x.py
192 :sign place 9 group=g2 priority=50 line=5
193 \ name=sign1 file=a.py
194<
Bram Moolenaarb328cca2019-01-06 16:24:01 +0100195:sign place {id} line={lnum} name={name} [buffer={nr}]
196 Same, but use buffer {nr}. If the buffer argument is not
197 given, place the sign in the current buffer.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000198
Bram Moolenaare968e362014-05-13 20:23:24 +0200199 *E885*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000200:sign place {id} name={name} file={fname}
201 Change the placed sign {id} in file {fname} to use the defined
202 sign {name}. See remark above about {fname} |:sign-fname|.
203 This can be used to change the displayed sign without moving
204 it (e.g., when the debugger has stopped at a breakpoint).
205
Bram Moolenaar162b7142018-12-21 15:17:36 +0100206 The optional "group={group}" attribute can be used before
Bram Moolenaar58a7f872019-06-04 22:48:15 +0200207 "file=" to select a sign in a particular group. The optional
208 "priority={prio}" attribute can be used to change the priority
209 of an existing sign.
Bram Moolenaar162b7142018-12-21 15:17:36 +0100210
Bram Moolenaarb328cca2019-01-06 16:24:01 +0100211:sign place {id} name={name} [buffer={nr}]
212 Same, but use buffer {nr}. If the buffer argument is not
213 given, use the current buffer.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000214
215
216REMOVING SIGNS *:sign-unplace* *E159*
217
Bram Moolenaar162b7142018-12-21 15:17:36 +0100218See |sign_unplace()| for the equivalent Vim script function.
219
Bram Moolenaar071d4272004-06-13 20:20:40 +0000220:sign unplace {id} file={fname}
221 Remove the previously placed sign {id} from file {fname}.
222 See remark above about {fname} |:sign-fname|.
223
Bram Moolenaar162b7142018-12-21 15:17:36 +0100224:sign unplace {id} group={group} file={fname}
225 Same but remove the sign {id} in sign group {group}.
226
227:sign unplace {id} group=* file={fname}
228 Same but remove the sign {id} from all the sign groups.
229
Bram Moolenaarf65e5662012-07-10 15:18:22 +0200230:sign unplace * file={fname}
231 Remove all placed signs in file {fname}.
232
Bram Moolenaar162b7142018-12-21 15:17:36 +0100233:sign unplace * group={group} file={fname}
234 Remove all placed signs in group {group} from file {fname}.
235
236:sign unplace * group=* file={fname}
237 Remove all placed signs in all the groups from file {fname}.
238
Bram Moolenaar071d4272004-06-13 20:20:40 +0000239:sign unplace {id} buffer={nr}
Bram Moolenaarf65e5662012-07-10 15:18:22 +0200240 Remove the previously placed sign {id} from buffer {nr}.
241
Bram Moolenaar162b7142018-12-21 15:17:36 +0100242:sign unplace {id} group={group} buffer={nr}
243 Remove the previously placed sign {id} in group {group} from
244 buffer {nr}.
245
246:sign unplace {id} group=* buffer={nr}
247 Remove the previously placed sign {id} in all the groups from
248 buffer {nr}.
249
Bram Moolenaarf65e5662012-07-10 15:18:22 +0200250:sign unplace * buffer={nr}
251 Remove all placed signs in buffer {nr}.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000252
Bram Moolenaar162b7142018-12-21 15:17:36 +0100253:sign unplace * group={group} buffer={nr}
254 Remove all placed signs in group {group} from buffer {nr}.
255
256:sign unplace * group=* buffer={nr}
257 Remove all placed signs in all the groups from buffer {nr}.
258
Bram Moolenaar071d4272004-06-13 20:20:40 +0000259:sign unplace {id}
260 Remove the previously placed sign {id} from all files it
261 appears in.
262
Bram Moolenaar162b7142018-12-21 15:17:36 +0100263:sign unplace {id} group={group}
264 Remove the previously placed sign {id} in group {group} from
265 all files it appears in.
266
267:sign unplace {id} group=*
268 Remove the previously placed sign {id} in all the groups from
269 all the files it appears in.
270
Bram Moolenaar071d4272004-06-13 20:20:40 +0000271:sign unplace *
Bram Moolenaar6b7b7192019-01-11 13:42:41 +0100272 Remove all placed signs in the global group from all the files.
Bram Moolenaar7d83bf42018-12-29 18:53:55 +0100273
274:sign unplace * group={group}
Bram Moolenaar6b7b7192019-01-11 13:42:41 +0100275 Remove all placed signs in group {group} from all the files.
Bram Moolenaar162b7142018-12-21 15:17:36 +0100276
277:sign unplace * group=*
Bram Moolenaar6b7b7192019-01-11 13:42:41 +0100278 Remove all placed signs in all the groups from all the files.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000279
280:sign unplace
Bram Moolenaar7d83bf42018-12-29 18:53:55 +0100281 Remove a placed sign at the cursor position. If multiple signs
282 are placed in the line, then only one is removed.
283
284:sign unplace group={group}
285 Remove a placed sign in group {group} at the cursor
286 position.
287
288:sign unplace group=*
289 Remove a placed sign in any group at the cursor position.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000290
291
Bram Moolenaar36782082013-11-28 13:53:34 +0100292LISTING PLACED SIGNS *:sign-place-list*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000293
Bram Moolenaar162b7142018-12-21 15:17:36 +0100294See |sign_getplaced()| for the equivalent Vim script function.
295
Bram Moolenaar071d4272004-06-13 20:20:40 +0000296:sign place file={fname}
297 List signs placed in file {fname}.
298 See remark above about {fname} |:sign-fname|.
299
Bram Moolenaar162b7142018-12-21 15:17:36 +0100300:sign place group={group} file={fname}
301 List signs in group {group} placed in file {fname}.
302
Bram Moolenaar7d83bf42018-12-29 18:53:55 +0100303:sign place group=* file={fname}
304 List signs in all the groups placed in file {fname}.
305
Bram Moolenaar071d4272004-06-13 20:20:40 +0000306:sign place buffer={nr}
307 List signs placed in buffer {nr}.
308
Bram Moolenaar162b7142018-12-21 15:17:36 +0100309:sign place group={group} buffer={nr}
310 List signs in group {group} placed in buffer {nr}.
311
Bram Moolenaar7d83bf42018-12-29 18:53:55 +0100312:sign place group=* buffer={nr}
313 List signs in all the groups placed in buffer {nr}.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000314
Bram Moolenaar7d83bf42018-12-29 18:53:55 +0100315:sign place List placed signs in the global group in all files.
Bram Moolenaarc8c88492018-12-27 23:59:26 +0100316
Bram Moolenaar162b7142018-12-21 15:17:36 +0100317:sign place group={group}
Bram Moolenaarc8c88492018-12-27 23:59:26 +0100318 List placed signs with sign group {group} in all files.
Bram Moolenaar162b7142018-12-21 15:17:36 +0100319
Bram Moolenaar7d83bf42018-12-29 18:53:55 +0100320:sign place group=*
321 List placed signs in all sign groups in all files.
322
Bram Moolenaar071d4272004-06-13 20:20:40 +0000323
324JUMPING TO A SIGN *:sign-jump* *E157*
325
Bram Moolenaar6b7b7192019-01-11 13:42:41 +0100326See |sign_jump()| for the equivalent Vim script function.
327
Bram Moolenaar071d4272004-06-13 20:20:40 +0000328:sign jump {id} file={fname}
329 Open the file {fname} or jump to the window that contains
330 {fname} and position the cursor at sign {id}.
331 See remark above about {fname} |:sign-fname|.
332 If the file isn't displayed in window and the current file can
333 not be |abandon|ed this fails.
334
Bram Moolenaar7d83bf42018-12-29 18:53:55 +0100335:sign jump {id} group={group} file={fname}
336 Same but jump to the sign in group {group}
337
Bram Moolenaarb328cca2019-01-06 16:24:01 +0100338:sign jump {id} [buffer={nr}] *E934*
Bram Moolenaar7571d552016-08-18 22:54:46 +0200339 Same, but use buffer {nr}. This fails if buffer {nr} does not
Bram Moolenaarb328cca2019-01-06 16:24:01 +0100340 have a name. If the buffer argument is not given, use the
341 current buffer.
Bram Moolenaar7571d552016-08-18 22:54:46 +0200342
Bram Moolenaarb328cca2019-01-06 16:24:01 +0100343:sign jump {id} group={group} [buffer={nr}]
Bram Moolenaar7d83bf42018-12-29 18:53:55 +0100344 Same but jump to the sign in group {group}
345
Bram Moolenaar071d4272004-06-13 20:20:40 +0000346
Bram Moolenaar91f84f62018-07-29 15:07:52 +0200347 vim:tw=78:ts=8:noet:ft=help:norl: