blob: 6eb11a052dde83bc031198744dd99551774d41a9 [file] [log] [blame]
Bram Moolenaarb328cca2019-01-06 16:24:01 +01001*sign.txt* For Vim version 8.1. Last change: 2019 Jan 06
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
13{Vi does not have any of these features}
14{only available when compiled with the |+signs| feature}
15
16==============================================================================
171. Introduction *sign-intro* *signs*
18
19When a debugger or other IDE tool is driving an editor it needs to be able
20to give specific highlights which quickly tell the user useful information
Bram Moolenaar402d2fe2005-04-15 21:00:38 +000021about the file. One example of this would be a debugger which had an icon
22in the left-hand column denoting a breakpoint. Another example might be an
23arrow representing the Program Counter (PC). The sign features allow both
Bram Moolenaar071d4272004-06-13 20:20:40 +000024placement of a sign, or icon, in the left-hand side of the window and
Bram Moolenaar402d2fe2005-04-15 21:00:38 +000025definition of a highlight which will be applied to that line. Displaying the
Bram Moolenaar071d4272004-06-13 20:20:40 +000026sign as an image is most likely only feasible in gvim (although Sun
Bram Moolenaar402d2fe2005-04-15 21:00:38 +000027Microsystem's dtterm does support this it's the only terminal emulator I know
Bram Moolenaar071d4272004-06-13 20:20:40 +000028of which does). A text sign and the highlight should be feasible in any color
29terminal emulator.
30
Bram Moolenaar402d2fe2005-04-15 21:00:38 +000031Signs and highlights are not useful just for debuggers. Sun's Visual
Bram Moolenaar071d4272004-06-13 20:20:40 +000032WorkShop uses signs and highlights to mark build errors and SourceBrowser
Bram Moolenaar402d2fe2005-04-15 21:00:38 +000033hits. Additionally, the debugger supports 8 to 10 different signs and
Bram Moolenaar071d4272004-06-13 20:20:40 +000034highlight colors. |workshop| Same for Netbeans |netbeans|.
35
36There are two steps in using signs:
37
381. Define the sign. This specifies the image, text and highlighting. For
39 example, you can define a "break" sign with an image of a stop roadsign and
40 text "!!".
41
422. Place the sign. This specifies the file and line number where the sign is
43 displayed. A defined sign can be placed several times in different lines
44 and files.
45
46When 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
58is assigned when placing the sign using the |sign-place| command or the
59|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
79==============================================================================
802. Commands *sign-commands* *:sig* *:sign*
81
Bram Moolenaar00a927d2010-05-14 23:24:24 +020082Here is an example that places a sign "piet", displayed with the text ">>", in
Bram Moolenaar071d4272004-06-13 20:20:40 +000083line 23 of the current file: >
84 :sign define piet text=>> texthl=Search
85 :exe ":sign place 2 line=23 name=piet file=" . expand("%:p")
86
87And here is the command to delete it again: >
88 :sign unplace 2
89
90Note that the ":sign" command cannot be followed by another command or a
91comment. If you do need that, use the |:execute| command.
92
93
94DEFINING A SIGN. *:sign-define* *E255* *E160* *E612*
95
Bram Moolenaar162b7142018-12-21 15:17:36 +010096See |sign_define()| for the equivalent Vim script function.
97
Bram Moolenaar071d4272004-06-13 20:20:40 +000098:sign define {name} {argument}...
99 Define a new sign or set attributes for an existing sign.
100 The {name} can either be a number (all digits) or a name
Bram Moolenaar4c05fa02019-01-01 15:32:17 +0100101 starting with a non-digit. Leading zeros are ignored, thus
Bram Moolenaar483c5d82010-10-20 18:45:33 +0200102 "0012", "012" and "12" are considered the same name.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000103 About 120 different signs can be defined.
104
105 Accepted arguments:
106
Bram Moolenaar6ee8d892012-01-10 14:55:01 +0100107 icon={bitmap}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000108 Define the file name where the bitmap can be found. Should be
109 a full path. The bitmap should fit in the place of two
110 characters. This is not checked. If the bitmap is too big it
111 will cause redraw problems. Only GTK 2 can scale the bitmap
112 to fit the space available.
113 toolkit supports ~
114 GTK 1 pixmap (.xpm)
115 GTK 2 many
116 Motif pixmap (.xpm)
Bram Moolenaar6ee8d892012-01-10 14:55:01 +0100117 Win32 .bmp, .ico, .cur
118 pixmap (.xpm) |+xpm_w32|
Bram Moolenaar071d4272004-06-13 20:20:40 +0000119
120 linehl={group}
121 Highlighting group used for the whole line the sign is placed
122 in. Most useful is defining a background color.
123
124 text={text} *E239*
125 Define the text that is displayed when there is no icon or the
126 GUI is not being used. Only printable characters are allowed
127 and they must occupy one or two display cells.
128
129 texthl={group}
130 Highlighting group used for the text item.
131
132
133DELETING A SIGN *:sign-undefine* *E155*
134
Bram Moolenaar162b7142018-12-21 15:17:36 +0100135See |sign_undefine()| for the equivalent Vim script function.
136
Bram Moolenaar071d4272004-06-13 20:20:40 +0000137:sign undefine {name}
138 Deletes a previously defined sign. If signs with this {name}
139 are still placed this will cause trouble.
140
141
Bram Moolenaar162b7142018-12-21 15:17:36 +0100142
Bram Moolenaar071d4272004-06-13 20:20:40 +0000143LISTING SIGNS *:sign-list* *E156*
144
Bram Moolenaar162b7142018-12-21 15:17:36 +0100145See |sign_getdefined()| for the equivalent Vim script function.
146
Bram Moolenaar071d4272004-06-13 20:20:40 +0000147:sign list Lists all defined signs and their attributes.
148
149:sign list {name}
150 Lists one defined sign and its attributes.
151
152
153PLACING SIGNS *:sign-place* *E158*
154
Bram Moolenaar162b7142018-12-21 15:17:36 +0100155See |sign_place()| for the equivalent Vim script function.
156
Bram Moolenaar071d4272004-06-13 20:20:40 +0000157:sign place {id} line={lnum} name={name} file={fname}
158 Place sign defined as {name} at line {lnum} in file {fname}.
159 *:sign-fname*
160 The file {fname} must already be loaded in a buffer. The
161 exact file name must be used, wildcards, $ENV and ~ are not
162 expanded, white space must not be escaped. Trailing white
163 space is ignored.
164
165 The sign is remembered under {id}, this can be used for
166 further manipulation. {id} must be a number.
167 It's up to the user to make sure the {id} is used only once in
168 each file (if it's used several times unplacing will also have
169 to be done several times and making changes may not work as
170 expected).
171
Bram Moolenaar162b7142018-12-21 15:17:36 +0100172 The following optional sign attributes can be specified before
173 "file=":
174 group={group} Place sign in sign group {group}
175 priority={prio} Assign priority {prio} to sign
176
177 By default, the sign is placed in the global sign group.
178
179 By default, the sign is assigned a default priority of 10. To
180 assign a different priority value, use "priority={prio}" to
181 specify a value. The priority is used to determine the
182 highlight group used when multiple signs are placed on the
183 same line.
184
185 Examples: >
186 :sign place 5 line=3 name=sign1 file=a.py
187 :sign place 6 group=g2 line=2 name=sign2 file=x.py
188 :sign place 9 group=g2 priority=50 line=5
189 \ name=sign1 file=a.py
190<
Bram Moolenaarb328cca2019-01-06 16:24:01 +0100191:sign place {id} line={lnum} name={name} [buffer={nr}]
192 Same, but use buffer {nr}. If the buffer argument is not
193 given, place the sign in the current buffer.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000194
Bram Moolenaare968e362014-05-13 20:23:24 +0200195 *E885*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000196:sign place {id} name={name} file={fname}
197 Change the placed sign {id} in file {fname} to use the defined
198 sign {name}. See remark above about {fname} |:sign-fname|.
199 This can be used to change the displayed sign without moving
200 it (e.g., when the debugger has stopped at a breakpoint).
201
Bram Moolenaar162b7142018-12-21 15:17:36 +0100202 The optional "group={group}" attribute can be used before
203 "file=" to select a sign in a particular group.
204
Bram Moolenaarb328cca2019-01-06 16:24:01 +0100205:sign place {id} name={name} [buffer={nr}]
206 Same, but use buffer {nr}. If the buffer argument is not
207 given, use the current buffer.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000208
209
210REMOVING SIGNS *:sign-unplace* *E159*
211
Bram Moolenaar162b7142018-12-21 15:17:36 +0100212See |sign_unplace()| for the equivalent Vim script function.
213
Bram Moolenaar071d4272004-06-13 20:20:40 +0000214:sign unplace {id} file={fname}
215 Remove the previously placed sign {id} from file {fname}.
216 See remark above about {fname} |:sign-fname|.
217
Bram Moolenaar162b7142018-12-21 15:17:36 +0100218:sign unplace {id} group={group} file={fname}
219 Same but remove the sign {id} in sign group {group}.
220
221:sign unplace {id} group=* file={fname}
222 Same but remove the sign {id} from all the sign groups.
223
Bram Moolenaarf65e5662012-07-10 15:18:22 +0200224:sign unplace * file={fname}
225 Remove all placed signs in file {fname}.
226
Bram Moolenaar162b7142018-12-21 15:17:36 +0100227:sign unplace * group={group} file={fname}
228 Remove all placed signs in group {group} from file {fname}.
229
230:sign unplace * group=* file={fname}
231 Remove all placed signs in all the groups from file {fname}.
232
Bram Moolenaar071d4272004-06-13 20:20:40 +0000233:sign unplace {id} buffer={nr}
Bram Moolenaarf65e5662012-07-10 15:18:22 +0200234 Remove the previously placed sign {id} from buffer {nr}.
235
Bram Moolenaar162b7142018-12-21 15:17:36 +0100236:sign unplace {id} group={group} buffer={nr}
237 Remove the previously placed sign {id} in group {group} from
238 buffer {nr}.
239
240:sign unplace {id} group=* buffer={nr}
241 Remove the previously placed sign {id} in all the groups from
242 buffer {nr}.
243
Bram Moolenaarf65e5662012-07-10 15:18:22 +0200244:sign unplace * buffer={nr}
245 Remove all placed signs in buffer {nr}.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000246
Bram Moolenaar162b7142018-12-21 15:17:36 +0100247:sign unplace * group={group} buffer={nr}
248 Remove all placed signs in group {group} from buffer {nr}.
249
250:sign unplace * group=* buffer={nr}
251 Remove all placed signs in all the groups from buffer {nr}.
252
Bram Moolenaar071d4272004-06-13 20:20:40 +0000253:sign unplace {id}
254 Remove the previously placed sign {id} from all files it
255 appears in.
256
Bram Moolenaar162b7142018-12-21 15:17:36 +0100257:sign unplace {id} group={group}
258 Remove the previously placed sign {id} in group {group} from
259 all files it appears in.
260
261:sign unplace {id} group=*
262 Remove the previously placed sign {id} in all the groups from
263 all the files it appears in.
264
Bram Moolenaar071d4272004-06-13 20:20:40 +0000265:sign unplace *
Bram Moolenaar7d83bf42018-12-29 18:53:55 +0100266 Remove placed signs in the global group from all the files.
267
268:sign unplace * group={group}
269 Remove placed signs in group {group} from all the files.
Bram Moolenaar162b7142018-12-21 15:17:36 +0100270
271:sign unplace * group=*
Bram Moolenaar7d83bf42018-12-29 18:53:55 +0100272 Remove placed signs in all the groups from all the files.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000273
274:sign unplace
Bram Moolenaar7d83bf42018-12-29 18:53:55 +0100275 Remove a placed sign at the cursor position. If multiple signs
276 are placed in the line, then only one is removed.
277
278:sign unplace group={group}
279 Remove a placed sign in group {group} at the cursor
280 position.
281
282:sign unplace group=*
283 Remove a placed sign in any group at the cursor position.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000284
285
Bram Moolenaar36782082013-11-28 13:53:34 +0100286LISTING PLACED SIGNS *:sign-place-list*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000287
Bram Moolenaar162b7142018-12-21 15:17:36 +0100288See |sign_getplaced()| for the equivalent Vim script function.
289
Bram Moolenaar071d4272004-06-13 20:20:40 +0000290:sign place file={fname}
291 List signs placed in file {fname}.
292 See remark above about {fname} |:sign-fname|.
293
Bram Moolenaar162b7142018-12-21 15:17:36 +0100294:sign place group={group} file={fname}
295 List signs in group {group} placed in file {fname}.
296
Bram Moolenaar7d83bf42018-12-29 18:53:55 +0100297:sign place group=* file={fname}
298 List signs in all the groups placed in file {fname}.
299
Bram Moolenaar071d4272004-06-13 20:20:40 +0000300:sign place buffer={nr}
301 List signs placed in buffer {nr}.
302
Bram Moolenaar162b7142018-12-21 15:17:36 +0100303:sign place group={group} buffer={nr}
304 List signs in group {group} placed in buffer {nr}.
305
Bram Moolenaar7d83bf42018-12-29 18:53:55 +0100306:sign place group=* buffer={nr}
307 List signs in all the groups placed in buffer {nr}.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000308
Bram Moolenaar7d83bf42018-12-29 18:53:55 +0100309:sign place List placed signs in the global group in all files.
Bram Moolenaarc8c88492018-12-27 23:59:26 +0100310
Bram Moolenaar162b7142018-12-21 15:17:36 +0100311:sign place group={group}
Bram Moolenaarc8c88492018-12-27 23:59:26 +0100312 List placed signs with sign group {group} in all files.
Bram Moolenaar162b7142018-12-21 15:17:36 +0100313
Bram Moolenaar7d83bf42018-12-29 18:53:55 +0100314:sign place group=*
315 List placed signs in all sign groups in all files.
316
Bram Moolenaar071d4272004-06-13 20:20:40 +0000317
318JUMPING TO A SIGN *:sign-jump* *E157*
319
320:sign jump {id} file={fname}
321 Open the file {fname} or jump to the window that contains
322 {fname} and position the cursor at sign {id}.
323 See remark above about {fname} |:sign-fname|.
324 If the file isn't displayed in window and the current file can
325 not be |abandon|ed this fails.
326
Bram Moolenaar7d83bf42018-12-29 18:53:55 +0100327:sign jump {id} group={group} file={fname}
328 Same but jump to the sign in group {group}
329
Bram Moolenaarb328cca2019-01-06 16:24:01 +0100330:sign jump {id} [buffer={nr}] *E934*
Bram Moolenaar7571d552016-08-18 22:54:46 +0200331 Same, but use buffer {nr}. This fails if buffer {nr} does not
Bram Moolenaarb328cca2019-01-06 16:24:01 +0100332 have a name. If the buffer argument is not given, use the
333 current buffer.
Bram Moolenaar7571d552016-08-18 22:54:46 +0200334
Bram Moolenaarb328cca2019-01-06 16:24:01 +0100335:sign jump {id} group={group} [buffer={nr}]
Bram Moolenaar7d83bf42018-12-29 18:53:55 +0100336 Same but jump to the sign in group {group}
337
Bram Moolenaar071d4272004-06-13 20:20:40 +0000338
Bram Moolenaar91f84f62018-07-29 15:07:52 +0200339 vim:tw=78:ts=8:noet:ft=help:norl: