blob: 115e1faa45d5115d3e8edfc039ab190e8b152e68 [file] [log] [blame]
Bram Moolenaar162b7142018-12-21 15:17:36 +01001*sign.txt* For Vim version 8.1. Last change: 2018 Dec 21
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<
55 *sign-group*
56Each sign can be assigned to either the global group or a named group. When
57placing a sign, if a group name is not supplied, or an empty string is used,
58then the sign is placed in the global group. Otherwise the sign is placed in
59the named group. The sign identifier is unique within a group. The sign group
60allows Vim plugins to use unique signs without interfering with other plugins
61using signs.
62
63 *sign-priority*
64Each placed sign is assigned a priority value. When multiple signs are placed
65on the same line, the attributes of the sign with the highest priority is used
66independent of the sign group. The default priority for a sign is 10. The
67priority is assigned at the time of placing a sign.
Bram Moolenaar071d4272004-06-13 20:20:40 +000068
69==============================================================================
702. Commands *sign-commands* *:sig* *:sign*
71
Bram Moolenaar00a927d2010-05-14 23:24:24 +020072Here is an example that places a sign "piet", displayed with the text ">>", in
Bram Moolenaar071d4272004-06-13 20:20:40 +000073line 23 of the current file: >
74 :sign define piet text=>> texthl=Search
75 :exe ":sign place 2 line=23 name=piet file=" . expand("%:p")
76
77And here is the command to delete it again: >
78 :sign unplace 2
79
80Note that the ":sign" command cannot be followed by another command or a
81comment. If you do need that, use the |:execute| command.
82
83
84DEFINING A SIGN. *:sign-define* *E255* *E160* *E612*
85
Bram Moolenaar162b7142018-12-21 15:17:36 +010086See |sign_define()| for the equivalent Vim script function.
87
Bram Moolenaar071d4272004-06-13 20:20:40 +000088:sign define {name} {argument}...
89 Define a new sign or set attributes for an existing sign.
90 The {name} can either be a number (all digits) or a name
Bram Moolenaar483c5d82010-10-20 18:45:33 +020091 starting with a non-digit. Leading digits are ignored, thus
92 "0012", "012" and "12" are considered the same name.
Bram Moolenaar071d4272004-06-13 20:20:40 +000093 About 120 different signs can be defined.
94
95 Accepted arguments:
96
Bram Moolenaar6ee8d892012-01-10 14:55:01 +010097 icon={bitmap}
Bram Moolenaar071d4272004-06-13 20:20:40 +000098 Define the file name where the bitmap can be found. Should be
99 a full path. The bitmap should fit in the place of two
100 characters. This is not checked. If the bitmap is too big it
101 will cause redraw problems. Only GTK 2 can scale the bitmap
102 to fit the space available.
103 toolkit supports ~
104 GTK 1 pixmap (.xpm)
105 GTK 2 many
106 Motif pixmap (.xpm)
Bram Moolenaar6ee8d892012-01-10 14:55:01 +0100107 Win32 .bmp, .ico, .cur
108 pixmap (.xpm) |+xpm_w32|
Bram Moolenaar071d4272004-06-13 20:20:40 +0000109
110 linehl={group}
111 Highlighting group used for the whole line the sign is placed
112 in. Most useful is defining a background color.
113
114 text={text} *E239*
115 Define the text that is displayed when there is no icon or the
116 GUI is not being used. Only printable characters are allowed
117 and they must occupy one or two display cells.
118
119 texthl={group}
120 Highlighting group used for the text item.
121
122
123DELETING A SIGN *:sign-undefine* *E155*
124
Bram Moolenaar162b7142018-12-21 15:17:36 +0100125See |sign_undefine()| for the equivalent Vim script function.
126
Bram Moolenaar071d4272004-06-13 20:20:40 +0000127:sign undefine {name}
128 Deletes a previously defined sign. If signs with this {name}
129 are still placed this will cause trouble.
130
131
Bram Moolenaar162b7142018-12-21 15:17:36 +0100132
Bram Moolenaar071d4272004-06-13 20:20:40 +0000133LISTING SIGNS *:sign-list* *E156*
134
Bram Moolenaar162b7142018-12-21 15:17:36 +0100135See |sign_getdefined()| for the equivalent Vim script function.
136
Bram Moolenaar071d4272004-06-13 20:20:40 +0000137:sign list Lists all defined signs and their attributes.
138
139:sign list {name}
140 Lists one defined sign and its attributes.
141
142
143PLACING SIGNS *:sign-place* *E158*
144
Bram Moolenaar162b7142018-12-21 15:17:36 +0100145See |sign_place()| for the equivalent Vim script function.
146
Bram Moolenaar071d4272004-06-13 20:20:40 +0000147:sign place {id} line={lnum} name={name} file={fname}
148 Place sign defined as {name} at line {lnum} in file {fname}.
149 *:sign-fname*
150 The file {fname} must already be loaded in a buffer. The
151 exact file name must be used, wildcards, $ENV and ~ are not
152 expanded, white space must not be escaped. Trailing white
153 space is ignored.
154
155 The sign is remembered under {id}, this can be used for
156 further manipulation. {id} must be a number.
157 It's up to the user to make sure the {id} is used only once in
158 each file (if it's used several times unplacing will also have
159 to be done several times and making changes may not work as
160 expected).
161
Bram Moolenaar162b7142018-12-21 15:17:36 +0100162 The following optional sign attributes can be specified before
163 "file=":
164 group={group} Place sign in sign group {group}
165 priority={prio} Assign priority {prio} to sign
166
167 By default, the sign is placed in the global sign group.
168
169 By default, the sign is assigned a default priority of 10. To
170 assign a different priority value, use "priority={prio}" to
171 specify a value. The priority is used to determine the
172 highlight group used when multiple signs are placed on the
173 same line.
174
175 Examples: >
176 :sign place 5 line=3 name=sign1 file=a.py
177 :sign place 6 group=g2 line=2 name=sign2 file=x.py
178 :sign place 9 group=g2 priority=50 line=5
179 \ name=sign1 file=a.py
180<
Bram Moolenaar071d4272004-06-13 20:20:40 +0000181:sign place {id} line={lnum} name={name} buffer={nr}
182 Same, but use buffer {nr}.
183
Bram Moolenaare968e362014-05-13 20:23:24 +0200184 *E885*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000185:sign place {id} name={name} file={fname}
186 Change the placed sign {id} in file {fname} to use the defined
187 sign {name}. See remark above about {fname} |:sign-fname|.
188 This can be used to change the displayed sign without moving
189 it (e.g., when the debugger has stopped at a breakpoint).
190
Bram Moolenaar162b7142018-12-21 15:17:36 +0100191 The optional "group={group}" attribute can be used before
192 "file=" to select a sign in a particular group.
193
Bram Moolenaar071d4272004-06-13 20:20:40 +0000194:sign place {id} name={name} buffer={nr}
195 Same, but use buffer {nr}.
196
197
198REMOVING SIGNS *:sign-unplace* *E159*
199
Bram Moolenaar162b7142018-12-21 15:17:36 +0100200See |sign_unplace()| for the equivalent Vim script function.
201
Bram Moolenaar071d4272004-06-13 20:20:40 +0000202:sign unplace {id} file={fname}
203 Remove the previously placed sign {id} from file {fname}.
204 See remark above about {fname} |:sign-fname|.
205
Bram Moolenaar162b7142018-12-21 15:17:36 +0100206:sign unplace {id} group={group} file={fname}
207 Same but remove the sign {id} in sign group {group}.
208
209:sign unplace {id} group=* file={fname}
210 Same but remove the sign {id} from all the sign groups.
211
Bram Moolenaarf65e5662012-07-10 15:18:22 +0200212:sign unplace * file={fname}
213 Remove all placed signs in file {fname}.
214
Bram Moolenaar162b7142018-12-21 15:17:36 +0100215:sign unplace * group={group} file={fname}
216 Remove all placed signs in group {group} from file {fname}.
217
218:sign unplace * group=* file={fname}
219 Remove all placed signs in all the groups from file {fname}.
220
Bram Moolenaar071d4272004-06-13 20:20:40 +0000221:sign unplace {id} buffer={nr}
Bram Moolenaarf65e5662012-07-10 15:18:22 +0200222 Remove the previously placed sign {id} from buffer {nr}.
223
Bram Moolenaar162b7142018-12-21 15:17:36 +0100224:sign unplace {id} group={group} buffer={nr}
225 Remove the previously placed sign {id} in group {group} from
226 buffer {nr}.
227
228:sign unplace {id} group=* buffer={nr}
229 Remove the previously placed sign {id} in all the groups from
230 buffer {nr}.
231
Bram Moolenaarf65e5662012-07-10 15:18:22 +0200232:sign unplace * buffer={nr}
233 Remove all placed signs in buffer {nr}.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000234
Bram Moolenaar162b7142018-12-21 15:17:36 +0100235:sign unplace * group={group} buffer={nr}
236 Remove all placed signs in group {group} from buffer {nr}.
237
238:sign unplace * group=* buffer={nr}
239 Remove all placed signs in all the groups from buffer {nr}.
240
Bram Moolenaar071d4272004-06-13 20:20:40 +0000241:sign unplace {id}
242 Remove the previously placed sign {id} from all files it
243 appears in.
244
Bram Moolenaar162b7142018-12-21 15:17:36 +0100245:sign unplace {id} group={group}
246 Remove the previously placed sign {id} in group {group} from
247 all files it appears in.
248
249:sign unplace {id} group=*
250 Remove the previously placed sign {id} in all the groups from
251 all the files it appears in.
252
Bram Moolenaar071d4272004-06-13 20:20:40 +0000253:sign unplace *
Bram Moolenaar162b7142018-12-21 15:17:36 +0100254 Remove all placed signs in the global group.
255
256:sign unplace * group=*
257 Remove all placed signs in all the groups.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000258
259:sign unplace
260 Remove the placed sign at the cursor position.
261
262
Bram Moolenaar36782082013-11-28 13:53:34 +0100263LISTING PLACED SIGNS *:sign-place-list*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000264
Bram Moolenaar162b7142018-12-21 15:17:36 +0100265See |sign_getplaced()| for the equivalent Vim script function.
266
Bram Moolenaar071d4272004-06-13 20:20:40 +0000267:sign place file={fname}
268 List signs placed in file {fname}.
269 See remark above about {fname} |:sign-fname|.
270
Bram Moolenaar162b7142018-12-21 15:17:36 +0100271:sign place group={group} file={fname}
272 List signs in group {group} placed in file {fname}.
273
Bram Moolenaar071d4272004-06-13 20:20:40 +0000274:sign place buffer={nr}
275 List signs placed in buffer {nr}.
276
Bram Moolenaar162b7142018-12-21 15:17:36 +0100277:sign place group={group} buffer={nr}
278 List signs in group {group} placed in buffer {nr}.
279
Bram Moolenaar071d4272004-06-13 20:20:40 +0000280:sign place List placed signs in all files.
281
Bram Moolenaar162b7142018-12-21 15:17:36 +0100282:sign place group={group}
283 List placed signs in all sign groups in all the files.
284
Bram Moolenaar071d4272004-06-13 20:20:40 +0000285
286JUMPING TO A SIGN *:sign-jump* *E157*
287
288:sign jump {id} file={fname}
289 Open the file {fname} or jump to the window that contains
290 {fname} and position the cursor at sign {id}.
291 See remark above about {fname} |:sign-fname|.
292 If the file isn't displayed in window and the current file can
293 not be |abandon|ed this fails.
294
Bram Moolenaar7571d552016-08-18 22:54:46 +0200295:sign jump {id} buffer={nr} *E934*
296 Same, but use buffer {nr}. This fails if buffer {nr} does not
297 have a name.
298
Bram Moolenaar071d4272004-06-13 20:20:40 +0000299
Bram Moolenaar91f84f62018-07-29 15:07:52 +0200300 vim:tw=78:ts=8:noet:ft=help:norl: