Bram Moolenaar | 3132cdd | 2020-11-05 20:41:49 +0100 | [diff] [blame] | 1 | *sign.txt* For Vim version 8.2. Last change: 2020 Oct 28 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2 | |
| 3 | |
| 4 | VIM REFERENCE MANUAL by Gordon Prieur |
| 5 | and Bram Moolenaar |
| 6 | |
| 7 | |
| 8 | Sign Support Features *sign-support* |
| 9 | |
| 10 | 1. Introduction |sign-intro| |
| 11 | 2. Commands |sign-commands| |
Bram Moolenaar | ed997ad | 2019-07-21 16:42:00 +0200 | [diff] [blame] | 12 | 3. Functions |sign-functions-details| |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 13 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 14 | {only available when compiled with the |+signs| feature} |
| 15 | |
| 16 | ============================================================================== |
| 17 | 1. Introduction *sign-intro* *signs* |
| 18 | |
| 19 | When a debugger or other IDE tool is driving an editor it needs to be able |
| 20 | to give specific highlights which quickly tell the user useful information |
Bram Moolenaar | 402d2fe | 2005-04-15 21:00:38 +0000 | [diff] [blame] | 21 | about the file. One example of this would be a debugger which had an icon |
| 22 | in the left-hand column denoting a breakpoint. Another example might be an |
| 23 | arrow representing the Program Counter (PC). The sign features allow both |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 24 | placement of a sign, or icon, in the left-hand side of the window and |
Bram Moolenaar | 402d2fe | 2005-04-15 21:00:38 +0000 | [diff] [blame] | 25 | definition of a highlight which will be applied to that line. Displaying the |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 26 | sign as an image is most likely only feasible in gvim (although Sun |
Bram Moolenaar | 402d2fe | 2005-04-15 21:00:38 +0000 | [diff] [blame] | 27 | Microsystem's dtterm does support this it's the only terminal emulator I know |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 28 | of which does). A text sign and the highlight should be feasible in any color |
| 29 | terminal emulator. |
| 30 | |
Bram Moolenaar | 402d2fe | 2005-04-15 21:00:38 +0000 | [diff] [blame] | 31 | Signs and highlights are not useful just for debuggers. Sun's Visual |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 32 | WorkShop uses signs and highlights to mark build errors and SourceBrowser |
Bram Moolenaar | 402d2fe | 2005-04-15 21:00:38 +0000 | [diff] [blame] | 33 | hits. Additionally, the debugger supports 8 to 10 different signs and |
Bram Moolenaar | d09091d | 2019-01-17 16:07:22 +0100 | [diff] [blame] | 34 | highlight colors, see |NetBeans|. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 35 | |
| 36 | There are two steps in using signs: |
| 37 | |
| 38 | 1. 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 | |
| 42 | 2. 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 | |
Bram Moolenaar | d09091d | 2019-01-17 16:07:22 +0100 | [diff] [blame] | 46 | *sign-column* |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 47 | When signs are defined for a file, Vim will automatically add a column of two |
| 48 | characters to display them in. When the last sign is unplaced the column |
Bram Moolenaar | 0952131 | 2016-08-12 22:54:35 +0200 | [diff] [blame] | 49 | disappears again. This behavior can be changed with the 'signcolumn' option. |
| 50 | |
Bram Moolenaar | 574ee7b | 2019-11-13 23:04:29 +0100 | [diff] [blame] | 51 | The color of the column is set with the SignColumn highlight group |
| 52 | |hl-SignColumn|. Example to set the color: > |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 53 | |
| 54 | :highlight SignColumn guibg=darkgrey |
Bram Moolenaar | 162b714 | 2018-12-21 15:17:36 +0100 | [diff] [blame] | 55 | < |
Bram Moolenaar | b328cca | 2019-01-06 16:24:01 +0100 | [diff] [blame] | 56 | *sign-identifier* |
| 57 | Each placed sign is identified by a number called the sign identifier. This |
| 58 | identifier is used to jump to the sign or to remove the sign. The identifier |
Bram Moolenaar | d09091d | 2019-01-17 16:07:22 +0100 | [diff] [blame] | 59 | is assigned when placing the sign using the |:sign-place| command or the |
Bram Moolenaar | b328cca | 2019-01-06 16:24:01 +0100 | [diff] [blame] | 60 | |sign_place()| function. Each sign identifier should be a unique number. If |
| 61 | multiple placed signs use the same identifier, then jumping to or removing a |
| 62 | sign becomes unpredictable. To avoid overlapping identifiers, sign groups can |
| 63 | be used. The |sign_place()| function can be called with a zero sign identifier |
| 64 | to allocate the next available identifier. |
| 65 | |
Bram Moolenaar | 162b714 | 2018-12-21 15:17:36 +0100 | [diff] [blame] | 66 | *sign-group* |
Bram Moolenaar | b328cca | 2019-01-06 16:24:01 +0100 | [diff] [blame] | 67 | Each placed sign can be assigned to either the global group or a named group. |
| 68 | When placing a sign, if a group name is not supplied, or an empty string is |
| 69 | used, then the sign is placed in the global group. Otherwise the sign is |
| 70 | placed in the named group. The sign identifier is unique within a group. The |
| 71 | sign group allows Vim plugins to use unique signs without interfering with |
| 72 | other plugins using signs. |
Bram Moolenaar | 162b714 | 2018-12-21 15:17:36 +0100 | [diff] [blame] | 73 | |
Bram Moolenaar | 7257073 | 2019-11-30 14:21:53 +0100 | [diff] [blame] | 74 | To place a sign in a popup window the group name must start with "PopUp". |
| 75 | Other signs will not show in a popup window. The group name "PopUpMenu" is |
| 76 | used by popup windows where 'cursorline' is set. |
| 77 | |
Bram Moolenaar | 162b714 | 2018-12-21 15:17:36 +0100 | [diff] [blame] | 78 | *sign-priority* |
| 79 | Each placed sign is assigned a priority value. When multiple signs are placed |
| 80 | on the same line, the attributes of the sign with the highest priority is used |
Bram Moolenaar | 2547aa9 | 2020-07-26 17:00:44 +0200 | [diff] [blame] | 81 | independently of the sign group. The default priority for a sign is 10. The |
Bram Moolenaar | 162b714 | 2018-12-21 15:17:36 +0100 | [diff] [blame] | 82 | priority is assigned at the time of placing a sign. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 83 | |
Bram Moolenaar | 3132cdd | 2020-11-05 20:41:49 +0100 | [diff] [blame] | 84 | When two signs with the same priority are present, and one has an icon or text |
| 85 | in the signcolumn while the other has line highlighting, then both are |
| 86 | displayed. |
| 87 | |
Bram Moolenaar | d09091d | 2019-01-17 16:07:22 +0100 | [diff] [blame] | 88 | When the line on which the sign is placed is deleted, the sign is moved to the |
| 89 | next line (or the last line of the buffer, if there is no next line). When |
| 90 | the delete is undone the sign does not move back. |
| 91 | |
Bram Moolenaar | 39f7aa3 | 2020-08-31 22:00:05 +0200 | [diff] [blame] | 92 | When a sign with line highlighting and 'cursorline' highlighting are both |
| 93 | present, if the priority is 100 or more then the sign highlighting takes |
| 94 | precedence, otherwise the 'cursorline' highlighting. |
| 95 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 96 | ============================================================================== |
| 97 | 2. Commands *sign-commands* *:sig* *:sign* |
| 98 | |
Bram Moolenaar | 00a927d | 2010-05-14 23:24:24 +0200 | [diff] [blame] | 99 | Here is an example that places a sign "piet", displayed with the text ">>", in |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 100 | line 23 of the current file: > |
| 101 | :sign define piet text=>> texthl=Search |
| 102 | :exe ":sign place 2 line=23 name=piet file=" . expand("%:p") |
| 103 | |
| 104 | And here is the command to delete it again: > |
| 105 | :sign unplace 2 |
| 106 | |
| 107 | Note that the ":sign" command cannot be followed by another command or a |
| 108 | comment. If you do need that, use the |:execute| command. |
| 109 | |
| 110 | |
| 111 | DEFINING A SIGN. *:sign-define* *E255* *E160* *E612* |
| 112 | |
Bram Moolenaar | 162b714 | 2018-12-21 15:17:36 +0100 | [diff] [blame] | 113 | See |sign_define()| for the equivalent Vim script function. |
| 114 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 115 | :sign define {name} {argument}... |
| 116 | Define a new sign or set attributes for an existing sign. |
| 117 | The {name} can either be a number (all digits) or a name |
Bram Moolenaar | 4c05fa0 | 2019-01-01 15:32:17 +0100 | [diff] [blame] | 118 | starting with a non-digit. Leading zeros are ignored, thus |
Bram Moolenaar | 483c5d8 | 2010-10-20 18:45:33 +0200 | [diff] [blame] | 119 | "0012", "012" and "12" are considered the same name. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 120 | About 120 different signs can be defined. |
| 121 | |
| 122 | Accepted arguments: |
| 123 | |
Bram Moolenaar | 6ee8d89 | 2012-01-10 14:55:01 +0100 | [diff] [blame] | 124 | icon={bitmap} |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 125 | Define the file name where the bitmap can be found. Should be |
| 126 | a full path. The bitmap should fit in the place of two |
| 127 | characters. This is not checked. If the bitmap is too big it |
| 128 | will cause redraw problems. Only GTK 2 can scale the bitmap |
| 129 | to fit the space available. |
| 130 | toolkit supports ~ |
| 131 | GTK 1 pixmap (.xpm) |
| 132 | GTK 2 many |
| 133 | Motif pixmap (.xpm) |
Bram Moolenaar | 6ee8d89 | 2012-01-10 14:55:01 +0100 | [diff] [blame] | 134 | Win32 .bmp, .ico, .cur |
| 135 | pixmap (.xpm) |+xpm_w32| |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 136 | |
| 137 | linehl={group} |
| 138 | Highlighting group used for the whole line the sign is placed |
| 139 | in. Most useful is defining a background color. |
| 140 | |
| 141 | text={text} *E239* |
| 142 | Define the text that is displayed when there is no icon or the |
| 143 | GUI is not being used. Only printable characters are allowed |
| 144 | and they must occupy one or two display cells. |
| 145 | |
| 146 | texthl={group} |
| 147 | Highlighting group used for the text item. |
| 148 | |
| 149 | |
| 150 | DELETING A SIGN *:sign-undefine* *E155* |
| 151 | |
Bram Moolenaar | 162b714 | 2018-12-21 15:17:36 +0100 | [diff] [blame] | 152 | See |sign_undefine()| for the equivalent Vim script function. |
| 153 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 154 | :sign undefine {name} |
| 155 | Deletes a previously defined sign. If signs with this {name} |
| 156 | are still placed this will cause trouble. |
| 157 | |
| 158 | |
Bram Moolenaar | 162b714 | 2018-12-21 15:17:36 +0100 | [diff] [blame] | 159 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 160 | LISTING SIGNS *:sign-list* *E156* |
| 161 | |
Bram Moolenaar | 162b714 | 2018-12-21 15:17:36 +0100 | [diff] [blame] | 162 | See |sign_getdefined()| for the equivalent Vim script function. |
| 163 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 164 | :sign list Lists all defined signs and their attributes. |
| 165 | |
| 166 | :sign list {name} |
| 167 | Lists one defined sign and its attributes. |
| 168 | |
| 169 | |
| 170 | PLACING SIGNS *:sign-place* *E158* |
| 171 | |
Bram Moolenaar | 162b714 | 2018-12-21 15:17:36 +0100 | [diff] [blame] | 172 | See |sign_place()| for the equivalent Vim script function. |
| 173 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 174 | :sign place {id} line={lnum} name={name} file={fname} |
| 175 | Place sign defined as {name} at line {lnum} in file {fname}. |
| 176 | *:sign-fname* |
| 177 | The file {fname} must already be loaded in a buffer. The |
| 178 | exact file name must be used, wildcards, $ENV and ~ are not |
| 179 | expanded, white space must not be escaped. Trailing white |
| 180 | space is ignored. |
| 181 | |
| 182 | The sign is remembered under {id}, this can be used for |
| 183 | further manipulation. {id} must be a number. |
| 184 | It's up to the user to make sure the {id} is used only once in |
| 185 | each file (if it's used several times unplacing will also have |
| 186 | to be done several times and making changes may not work as |
| 187 | expected). |
| 188 | |
Bram Moolenaar | 162b714 | 2018-12-21 15:17:36 +0100 | [diff] [blame] | 189 | The following optional sign attributes can be specified before |
| 190 | "file=": |
| 191 | group={group} Place sign in sign group {group} |
| 192 | priority={prio} Assign priority {prio} to sign |
| 193 | |
| 194 | By default, the sign is placed in the global sign group. |
| 195 | |
| 196 | By default, the sign is assigned a default priority of 10. To |
| 197 | assign a different priority value, use "priority={prio}" to |
Bram Moolenaar | 58a7f87 | 2019-06-04 22:48:15 +0200 | [diff] [blame] | 198 | specify a value. The priority is used to determine the sign |
| 199 | that is displayed when multiple signs are placed on the same |
| 200 | line. |
Bram Moolenaar | 162b714 | 2018-12-21 15:17:36 +0100 | [diff] [blame] | 201 | |
| 202 | Examples: > |
| 203 | :sign place 5 line=3 name=sign1 file=a.py |
| 204 | :sign place 6 group=g2 line=2 name=sign2 file=x.py |
| 205 | :sign place 9 group=g2 priority=50 line=5 |
| 206 | \ name=sign1 file=a.py |
| 207 | < |
Bram Moolenaar | b328cca | 2019-01-06 16:24:01 +0100 | [diff] [blame] | 208 | :sign place {id} line={lnum} name={name} [buffer={nr}] |
| 209 | Same, but use buffer {nr}. If the buffer argument is not |
| 210 | given, place the sign in the current buffer. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 211 | |
Bram Moolenaar | e968e36 | 2014-05-13 20:23:24 +0200 | [diff] [blame] | 212 | *E885* |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 213 | :sign place {id} name={name} file={fname} |
| 214 | Change the placed sign {id} in file {fname} to use the defined |
| 215 | sign {name}. See remark above about {fname} |:sign-fname|. |
| 216 | This can be used to change the displayed sign without moving |
| 217 | it (e.g., when the debugger has stopped at a breakpoint). |
| 218 | |
Bram Moolenaar | 162b714 | 2018-12-21 15:17:36 +0100 | [diff] [blame] | 219 | The optional "group={group}" attribute can be used before |
Bram Moolenaar | 58a7f87 | 2019-06-04 22:48:15 +0200 | [diff] [blame] | 220 | "file=" to select a sign in a particular group. The optional |
| 221 | "priority={prio}" attribute can be used to change the priority |
| 222 | of an existing sign. |
Bram Moolenaar | 162b714 | 2018-12-21 15:17:36 +0100 | [diff] [blame] | 223 | |
Bram Moolenaar | b328cca | 2019-01-06 16:24:01 +0100 | [diff] [blame] | 224 | :sign place {id} name={name} [buffer={nr}] |
| 225 | Same, but use buffer {nr}. If the buffer argument is not |
| 226 | given, use the current buffer. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 227 | |
| 228 | |
| 229 | REMOVING SIGNS *:sign-unplace* *E159* |
| 230 | |
Bram Moolenaar | 162b714 | 2018-12-21 15:17:36 +0100 | [diff] [blame] | 231 | See |sign_unplace()| for the equivalent Vim script function. |
| 232 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 233 | :sign unplace {id} file={fname} |
| 234 | Remove the previously placed sign {id} from file {fname}. |
| 235 | See remark above about {fname} |:sign-fname|. |
| 236 | |
Bram Moolenaar | 162b714 | 2018-12-21 15:17:36 +0100 | [diff] [blame] | 237 | :sign unplace {id} group={group} file={fname} |
| 238 | Same but remove the sign {id} in sign group {group}. |
| 239 | |
| 240 | :sign unplace {id} group=* file={fname} |
| 241 | Same but remove the sign {id} from all the sign groups. |
| 242 | |
Bram Moolenaar | f65e566 | 2012-07-10 15:18:22 +0200 | [diff] [blame] | 243 | :sign unplace * file={fname} |
| 244 | Remove all placed signs in file {fname}. |
| 245 | |
Bram Moolenaar | 162b714 | 2018-12-21 15:17:36 +0100 | [diff] [blame] | 246 | :sign unplace * group={group} file={fname} |
| 247 | Remove all placed signs in group {group} from file {fname}. |
| 248 | |
| 249 | :sign unplace * group=* file={fname} |
| 250 | Remove all placed signs in all the groups from file {fname}. |
| 251 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 252 | :sign unplace {id} buffer={nr} |
Bram Moolenaar | f65e566 | 2012-07-10 15:18:22 +0200 | [diff] [blame] | 253 | Remove the previously placed sign {id} from buffer {nr}. |
| 254 | |
Bram Moolenaar | 162b714 | 2018-12-21 15:17:36 +0100 | [diff] [blame] | 255 | :sign unplace {id} group={group} buffer={nr} |
| 256 | Remove the previously placed sign {id} in group {group} from |
| 257 | buffer {nr}. |
| 258 | |
| 259 | :sign unplace {id} group=* buffer={nr} |
| 260 | Remove the previously placed sign {id} in all the groups from |
| 261 | buffer {nr}. |
| 262 | |
Bram Moolenaar | f65e566 | 2012-07-10 15:18:22 +0200 | [diff] [blame] | 263 | :sign unplace * buffer={nr} |
| 264 | Remove all placed signs in buffer {nr}. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 265 | |
Bram Moolenaar | 162b714 | 2018-12-21 15:17:36 +0100 | [diff] [blame] | 266 | :sign unplace * group={group} buffer={nr} |
| 267 | Remove all placed signs in group {group} from buffer {nr}. |
| 268 | |
| 269 | :sign unplace * group=* buffer={nr} |
| 270 | Remove all placed signs in all the groups from buffer {nr}. |
| 271 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 272 | :sign unplace {id} |
| 273 | Remove the previously placed sign {id} from all files it |
| 274 | appears in. |
| 275 | |
Bram Moolenaar | 162b714 | 2018-12-21 15:17:36 +0100 | [diff] [blame] | 276 | :sign unplace {id} group={group} |
| 277 | Remove the previously placed sign {id} in group {group} from |
| 278 | all files it appears in. |
| 279 | |
| 280 | :sign unplace {id} group=* |
| 281 | Remove the previously placed sign {id} in all the groups from |
| 282 | all the files it appears in. |
| 283 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 284 | :sign unplace * |
Bram Moolenaar | 6b7b719 | 2019-01-11 13:42:41 +0100 | [diff] [blame] | 285 | Remove all placed signs in the global group from all the files. |
Bram Moolenaar | 7d83bf4 | 2018-12-29 18:53:55 +0100 | [diff] [blame] | 286 | |
| 287 | :sign unplace * group={group} |
Bram Moolenaar | 6b7b719 | 2019-01-11 13:42:41 +0100 | [diff] [blame] | 288 | Remove all placed signs in group {group} from all the files. |
Bram Moolenaar | 162b714 | 2018-12-21 15:17:36 +0100 | [diff] [blame] | 289 | |
| 290 | :sign unplace * group=* |
Bram Moolenaar | 6b7b719 | 2019-01-11 13:42:41 +0100 | [diff] [blame] | 291 | Remove all placed signs in all the groups from all the files. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 292 | |
| 293 | :sign unplace |
Bram Moolenaar | 7d83bf4 | 2018-12-29 18:53:55 +0100 | [diff] [blame] | 294 | Remove a placed sign at the cursor position. If multiple signs |
| 295 | are placed in the line, then only one is removed. |
| 296 | |
| 297 | :sign unplace group={group} |
| 298 | Remove a placed sign in group {group} at the cursor |
| 299 | position. |
| 300 | |
| 301 | :sign unplace group=* |
| 302 | Remove a placed sign in any group at the cursor position. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 303 | |
| 304 | |
Bram Moolenaar | 3678208 | 2013-11-28 13:53:34 +0100 | [diff] [blame] | 305 | LISTING PLACED SIGNS *:sign-place-list* |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 306 | |
Bram Moolenaar | 162b714 | 2018-12-21 15:17:36 +0100 | [diff] [blame] | 307 | See |sign_getplaced()| for the equivalent Vim script function. |
| 308 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 309 | :sign place file={fname} |
| 310 | List signs placed in file {fname}. |
| 311 | See remark above about {fname} |:sign-fname|. |
| 312 | |
Bram Moolenaar | 162b714 | 2018-12-21 15:17:36 +0100 | [diff] [blame] | 313 | :sign place group={group} file={fname} |
| 314 | List signs in group {group} placed in file {fname}. |
| 315 | |
Bram Moolenaar | 7d83bf4 | 2018-12-29 18:53:55 +0100 | [diff] [blame] | 316 | :sign place group=* file={fname} |
| 317 | List signs in all the groups placed in file {fname}. |
| 318 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 319 | :sign place buffer={nr} |
| 320 | List signs placed in buffer {nr}. |
| 321 | |
Bram Moolenaar | 162b714 | 2018-12-21 15:17:36 +0100 | [diff] [blame] | 322 | :sign place group={group} buffer={nr} |
| 323 | List signs in group {group} placed in buffer {nr}. |
| 324 | |
Bram Moolenaar | 7d83bf4 | 2018-12-29 18:53:55 +0100 | [diff] [blame] | 325 | :sign place group=* buffer={nr} |
| 326 | List signs in all the groups placed in buffer {nr}. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 327 | |
Bram Moolenaar | 7d83bf4 | 2018-12-29 18:53:55 +0100 | [diff] [blame] | 328 | :sign place List placed signs in the global group in all files. |
Bram Moolenaar | c8c8849 | 2018-12-27 23:59:26 +0100 | [diff] [blame] | 329 | |
Bram Moolenaar | 162b714 | 2018-12-21 15:17:36 +0100 | [diff] [blame] | 330 | :sign place group={group} |
Bram Moolenaar | c8c8849 | 2018-12-27 23:59:26 +0100 | [diff] [blame] | 331 | List placed signs with sign group {group} in all files. |
Bram Moolenaar | 162b714 | 2018-12-21 15:17:36 +0100 | [diff] [blame] | 332 | |
Bram Moolenaar | 7d83bf4 | 2018-12-29 18:53:55 +0100 | [diff] [blame] | 333 | :sign place group=* |
| 334 | List placed signs in all sign groups in all files. |
| 335 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 336 | |
| 337 | JUMPING TO A SIGN *:sign-jump* *E157* |
| 338 | |
Bram Moolenaar | 6b7b719 | 2019-01-11 13:42:41 +0100 | [diff] [blame] | 339 | See |sign_jump()| for the equivalent Vim script function. |
| 340 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 341 | :sign jump {id} file={fname} |
| 342 | Open the file {fname} or jump to the window that contains |
| 343 | {fname} and position the cursor at sign {id}. |
| 344 | See remark above about {fname} |:sign-fname|. |
| 345 | If the file isn't displayed in window and the current file can |
| 346 | not be |abandon|ed this fails. |
| 347 | |
Bram Moolenaar | 7d83bf4 | 2018-12-29 18:53:55 +0100 | [diff] [blame] | 348 | :sign jump {id} group={group} file={fname} |
| 349 | Same but jump to the sign in group {group} |
| 350 | |
Bram Moolenaar | b328cca | 2019-01-06 16:24:01 +0100 | [diff] [blame] | 351 | :sign jump {id} [buffer={nr}] *E934* |
Bram Moolenaar | 7571d55 | 2016-08-18 22:54:46 +0200 | [diff] [blame] | 352 | Same, but use buffer {nr}. This fails if buffer {nr} does not |
Bram Moolenaar | b328cca | 2019-01-06 16:24:01 +0100 | [diff] [blame] | 353 | have a name. If the buffer argument is not given, use the |
| 354 | current buffer. |
Bram Moolenaar | 7571d55 | 2016-08-18 22:54:46 +0200 | [diff] [blame] | 355 | |
Bram Moolenaar | b328cca | 2019-01-06 16:24:01 +0100 | [diff] [blame] | 356 | :sign jump {id} group={group} [buffer={nr}] |
Bram Moolenaar | 7d83bf4 | 2018-12-29 18:53:55 +0100 | [diff] [blame] | 357 | Same but jump to the sign in group {group} |
| 358 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 359 | |
Bram Moolenaar | ed997ad | 2019-07-21 16:42:00 +0200 | [diff] [blame] | 360 | ============================================================================== |
| 361 | 3. Functions *sign-functions-details* |
| 362 | |
| 363 | sign_define({name} [, {dict}]) *sign_define()* |
| 364 | sign_define({list}) |
| 365 | Define a new sign named {name} or modify the attributes of an |
| 366 | existing sign. This is similar to the |:sign-define| command. |
| 367 | |
| 368 | Prefix {name} with a unique text to avoid name collisions. |
| 369 | There is no {group} like with placing signs. |
| 370 | |
| 371 | The {name} can be a String or a Number. The optional {dict} |
| 372 | argument specifies the sign attributes. The following values |
| 373 | are supported: |
| 374 | icon full path to the bitmap file for the sign. |
| 375 | linehl highlight group used for the whole line the |
| 376 | sign is placed in. |
| 377 | text text that is displayed when there is no icon |
| 378 | or the GUI is not being used. |
| 379 | texthl highlight group used for the text item |
| 380 | |
| 381 | If the sign named {name} already exists, then the attributes |
| 382 | of the sign are updated. |
| 383 | |
| 384 | The one argument {list} can be used to define a list of signs. |
| 385 | Each list item is a dictionary with the above items in {dict} |
Bram Moolenaar | 0c0734d | 2019-11-26 21:44:46 +0100 | [diff] [blame] | 386 | and a "name" item for the sign name. |
Bram Moolenaar | ed997ad | 2019-07-21 16:42:00 +0200 | [diff] [blame] | 387 | |
| 388 | Returns 0 on success and -1 on failure. When the one argument |
| 389 | {list} is used, then returns a List of values one for each |
| 390 | defined sign. |
| 391 | |
| 392 | Examples: > |
| 393 | call sign_define("mySign", { |
| 394 | \ "text" : "=>", |
| 395 | \ "texthl" : "Error", |
| 396 | \ "linehl" : "Search"}) |
| 397 | call sign_define([ |
| 398 | \ {'name' : 'sign1', |
| 399 | \ 'text' : '=>'}, |
| 400 | \ {'name' : 'sign2', |
| 401 | \ 'text' : '!!'} |
| 402 | \ ]) |
| 403 | < |
Bram Moolenaar | 93476fd | 2019-09-06 22:00:54 +0200 | [diff] [blame] | 404 | Can also be used as a |method|: > |
| 405 | GetSignList()->sign_define() |
| 406 | |
Bram Moolenaar | ed997ad | 2019-07-21 16:42:00 +0200 | [diff] [blame] | 407 | sign_getdefined([{name}]) *sign_getdefined()* |
| 408 | Get a list of defined signs and their attributes. |
| 409 | This is similar to the |:sign-list| command. |
| 410 | |
| 411 | If the {name} is not supplied, then a list of all the defined |
| 412 | signs is returned. Otherwise the attribute of the specified |
| 413 | sign is returned. |
| 414 | |
| 415 | Each list item in the returned value is a dictionary with the |
| 416 | following entries: |
| 417 | icon full path to the bitmap file of the sign |
| 418 | linehl highlight group used for the whole line the |
| 419 | sign is placed in. |
| 420 | name name of the sign |
| 421 | text text that is displayed when there is no icon |
| 422 | or the GUI is not being used. |
| 423 | texthl highlight group used for the text item |
| 424 | |
| 425 | Returns an empty List if there are no signs and when {name} is |
| 426 | not found. |
| 427 | |
| 428 | Examples: > |
| 429 | " Get a list of all the defined signs |
| 430 | echo sign_getdefined() |
| 431 | |
| 432 | " Get the attribute of the sign named mySign |
| 433 | echo sign_getdefined("mySign") |
| 434 | < |
Bram Moolenaar | 93476fd | 2019-09-06 22:00:54 +0200 | [diff] [blame] | 435 | Can also be used as a |method|: > |
| 436 | GetSignList()->sign_getdefined() |
| 437 | |
Bram Moolenaar | ed997ad | 2019-07-21 16:42:00 +0200 | [diff] [blame] | 438 | sign_getplaced([{expr} [, {dict}]]) *sign_getplaced()* |
| 439 | Return a list of signs placed in a buffer or all the buffers. |
| 440 | This is similar to the |:sign-place-list| command. |
| 441 | |
| 442 | If the optional buffer name {expr} is specified, then only the |
| 443 | list of signs placed in that buffer is returned. For the use |
| 444 | of {expr}, see |bufname()|. The optional {dict} can contain |
| 445 | the following entries: |
| 446 | group select only signs in this group |
| 447 | id select sign with this identifier |
| 448 | lnum select signs placed in this line. For the use |
| 449 | of {lnum}, see |line()|. |
| 450 | If {group} is '*', then signs in all the groups including the |
| 451 | global group are returned. If {group} is not supplied or is an |
| 452 | empty string, then only signs in the global group are |
| 453 | returned. If no arguments are supplied, then signs in the |
| 454 | global group placed in all the buffers are returned. |
| 455 | See |sign-group|. |
| 456 | |
| 457 | Each list item in the returned value is a dictionary with the |
| 458 | following entries: |
| 459 | bufnr number of the buffer with the sign |
| 460 | signs list of signs placed in {bufnr}. Each list |
| 461 | item is a dictionary with the below listed |
| 462 | entries |
| 463 | |
| 464 | The dictionary for each sign contains the following entries: |
Bram Moolenaar | 3132cdd | 2020-11-05 20:41:49 +0100 | [diff] [blame] | 465 | group sign group. Set to '' for the global group. |
| 466 | id identifier of the sign |
| 467 | lnum line number where the sign is placed |
| 468 | name name of the defined sign |
| 469 | priority sign priority |
Bram Moolenaar | ed997ad | 2019-07-21 16:42:00 +0200 | [diff] [blame] | 470 | |
| 471 | The returned signs in a buffer are ordered by their line |
| 472 | number and priority. |
| 473 | |
| 474 | Returns an empty list on failure or if there are no placed |
| 475 | signs. |
| 476 | |
| 477 | Examples: > |
| 478 | " Get a List of signs placed in eval.c in the |
| 479 | " global group |
| 480 | echo sign_getplaced("eval.c") |
| 481 | |
| 482 | " Get a List of signs in group 'g1' placed in eval.c |
| 483 | echo sign_getplaced("eval.c", {'group' : 'g1'}) |
| 484 | |
| 485 | " Get a List of signs placed at line 10 in eval.c |
| 486 | echo sign_getplaced("eval.c", {'lnum' : 10}) |
| 487 | |
| 488 | " Get sign with identifier 10 placed in a.py |
| 489 | echo sign_getplaced("a.py", {'id' : 10}) |
| 490 | |
| 491 | " Get sign with id 20 in group 'g1' placed in a.py |
| 492 | echo sign_getplaced("a.py", {'group' : 'g1', |
| 493 | \ 'id' : 20}) |
| 494 | |
| 495 | " Get a List of all the placed signs |
| 496 | echo sign_getplaced() |
| 497 | < |
Bram Moolenaar | 93476fd | 2019-09-06 22:00:54 +0200 | [diff] [blame] | 498 | Can also be used as a |method|: > |
| 499 | GetBufname()->sign_getplaced() |
| 500 | < |
Bram Moolenaar | ed997ad | 2019-07-21 16:42:00 +0200 | [diff] [blame] | 501 | *sign_jump()* |
| 502 | sign_jump({id}, {group}, {expr}) |
| 503 | Open the buffer {expr} or jump to the window that contains |
| 504 | {expr} and position the cursor at sign {id} in group {group}. |
| 505 | This is similar to the |:sign-jump| command. |
| 506 | |
| 507 | For the use of {expr}, see |bufname()|. |
| 508 | |
| 509 | Returns the line number of the sign. Returns -1 if the |
| 510 | arguments are invalid. |
| 511 | |
| 512 | Example: > |
| 513 | " Jump to sign 10 in the current buffer |
| 514 | call sign_jump(10, '', '') |
| 515 | < |
Bram Moolenaar | 93476fd | 2019-09-06 22:00:54 +0200 | [diff] [blame] | 516 | Can also be used as a |method|: > |
| 517 | GetSignid()->sign_jump() |
| 518 | < |
Bram Moolenaar | ed997ad | 2019-07-21 16:42:00 +0200 | [diff] [blame] | 519 | *sign_place()* |
| 520 | sign_place({id}, {group}, {name}, {expr} [, {dict}]) |
| 521 | Place the sign defined as {name} at line {lnum} in file or |
| 522 | buffer {expr} and assign {id} and {group} to sign. This is |
| 523 | similar to the |:sign-place| command. |
| 524 | |
| 525 | If the sign identifier {id} is zero, then a new identifier is |
| 526 | allocated. Otherwise the specified number is used. {group} is |
| 527 | the sign group name. To use the global sign group, use an |
| 528 | empty string. {group} functions as a namespace for {id}, thus |
| 529 | two groups can use the same IDs. Refer to |sign-identifier| |
| 530 | and |sign-group| for more information. |
| 531 | |
| 532 | {name} refers to a defined sign. |
| 533 | {expr} refers to a buffer name or number. For the accepted |
| 534 | values, see |bufname()|. |
| 535 | |
| 536 | The optional {dict} argument supports the following entries: |
| 537 | lnum line number in the file or buffer |
| 538 | {expr} where the sign is to be placed. |
| 539 | For the accepted values, see |line()|. |
| 540 | priority priority of the sign. See |
| 541 | |sign-priority| for more information. |
| 542 | |
| 543 | If the optional {dict} is not specified, then it modifies the |
| 544 | placed sign {id} in group {group} to use the defined sign |
| 545 | {name}. |
| 546 | |
| 547 | Returns the sign identifier on success and -1 on failure. |
| 548 | |
| 549 | Examples: > |
| 550 | " Place a sign named sign1 with id 5 at line 20 in |
| 551 | " buffer json.c |
| 552 | call sign_place(5, '', 'sign1', 'json.c', |
| 553 | \ {'lnum' : 20}) |
| 554 | |
| 555 | " Updates sign 5 in buffer json.c to use sign2 |
| 556 | call sign_place(5, '', 'sign2', 'json.c') |
| 557 | |
| 558 | " Place a sign named sign3 at line 30 in |
| 559 | " buffer json.c with a new identifier |
| 560 | let id = sign_place(0, '', 'sign3', 'json.c', |
| 561 | \ {'lnum' : 30}) |
| 562 | |
| 563 | " Place a sign named sign4 with id 10 in group 'g3' |
| 564 | " at line 40 in buffer json.c with priority 90 |
| 565 | call sign_place(10, 'g3', 'sign4', 'json.c', |
| 566 | \ {'lnum' : 40, 'priority' : 90}) |
| 567 | < |
Bram Moolenaar | 93476fd | 2019-09-06 22:00:54 +0200 | [diff] [blame] | 568 | Can also be used as a |method|: > |
| 569 | GetSignid()->sign_place(group, name, expr) |
| 570 | < |
Bram Moolenaar | ed997ad | 2019-07-21 16:42:00 +0200 | [diff] [blame] | 571 | *sign_placelist()* |
| 572 | sign_placelist({list}) |
| 573 | Place one or more signs. This is similar to the |
| 574 | |sign_place()| function. The {list} argument specifies the |
| 575 | List of signs to place. Each list item is a dict with the |
| 576 | following sign attributes: |
| 577 | buffer buffer name or number. For the accepted |
| 578 | values, see |bufname()|. |
| 579 | group sign group. {group} functions as a namespace |
| 580 | for {id}, thus two groups can use the same |
| 581 | IDs. If not specified or set to an empty |
| 582 | string, then the global group is used. See |
| 583 | |sign-group| for more information. |
| 584 | id sign identifier. If not specified or zero, |
| 585 | then a new unique identifier is allocated. |
| 586 | Otherwise the specified number is used. See |
| 587 | |sign-identifier| for more information. |
| 588 | lnum line number in the buffer {expr} where the |
| 589 | sign is to be placed. For the accepted values, |
| 590 | see |line()|. |
| 591 | name name of the sign to place. See |sign_define()| |
| 592 | for more information. |
| 593 | priority priority of the sign. When multiple signs are |
| 594 | placed on a line, the sign with the highest |
| 595 | priority is used. If not specified, the |
| 596 | default value of 10 is used. See |
| 597 | |sign-priority| for more information. |
| 598 | |
| 599 | If {id} refers to an existing sign, then the existing sign is |
| 600 | modified to use the specified {name} and/or {priority}. |
| 601 | |
| 602 | Returns a List of sign identifiers. If failed to place a |
| 603 | sign, the corresponding list item is set to -1. |
| 604 | |
| 605 | Examples: > |
| 606 | " Place sign s1 with id 5 at line 20 and id 10 at line |
| 607 | " 30 in buffer a.c |
| 608 | let [n1, n2] = sign_placelist([ |
| 609 | \ {'id' : 5, |
| 610 | \ 'name' : 's1', |
| 611 | \ 'buffer' : 'a.c', |
| 612 | \ 'lnum' : 20}, |
| 613 | \ {'id' : 10, |
| 614 | \ 'name' : 's1', |
| 615 | \ 'buffer' : 'a.c', |
| 616 | \ 'lnum' : 30} |
| 617 | \ ]) |
| 618 | |
| 619 | " Place sign s1 in buffer a.c at line 40 and 50 |
| 620 | " with auto-generated identifiers |
| 621 | let [n1, n2] = sign_placelist([ |
| 622 | \ {'name' : 's1', |
| 623 | \ 'buffer' : 'a.c', |
| 624 | \ 'lnum' : 40}, |
| 625 | \ {'name' : 's1', |
| 626 | \ 'buffer' : 'a.c', |
| 627 | \ 'lnum' : 50} |
| 628 | \ ]) |
| 629 | < |
Bram Moolenaar | 93476fd | 2019-09-06 22:00:54 +0200 | [diff] [blame] | 630 | Can also be used as a |method|: > |
| 631 | GetSignlist()->sign_placelist() |
Bram Moolenaar | ed997ad | 2019-07-21 16:42:00 +0200 | [diff] [blame] | 632 | |
| 633 | sign_undefine([{name}]) *sign_undefine()* |
| 634 | sign_undefine({list}) |
| 635 | Deletes a previously defined sign {name}. This is similar to |
| 636 | the |:sign-undefine| command. If {name} is not supplied, then |
| 637 | deletes all the defined signs. |
| 638 | |
| 639 | The one argument {list} can be used to undefine a list of |
| 640 | signs. Each list item is the name of a sign. |
| 641 | |
| 642 | Returns 0 on success and -1 on failure. For the one argument |
| 643 | {list} call, returns a list of values one for each undefined |
| 644 | sign. |
| 645 | |
| 646 | Examples: > |
| 647 | " Delete a sign named mySign |
| 648 | call sign_undefine("mySign") |
| 649 | |
| 650 | " Delete signs 'sign1' and 'sign2' |
| 651 | call sign_undefine(["sign1", "sign2"]) |
| 652 | |
| 653 | " Delete all the signs |
| 654 | call sign_undefine() |
| 655 | < |
Bram Moolenaar | 93476fd | 2019-09-06 22:00:54 +0200 | [diff] [blame] | 656 | Can also be used as a |method|: > |
| 657 | GetSignlist()->sign_undefine() |
Bram Moolenaar | ed997ad | 2019-07-21 16:42:00 +0200 | [diff] [blame] | 658 | |
| 659 | sign_unplace({group} [, {dict}]) *sign_unplace()* |
| 660 | Remove a previously placed sign in one or more buffers. This |
| 661 | is similar to the |:sign-unplace| command. |
| 662 | |
| 663 | {group} is the sign group name. To use the global sign group, |
| 664 | use an empty string. If {group} is set to '*', then all the |
| 665 | groups including the global group are used. |
| 666 | The signs in {group} are selected based on the entries in |
| 667 | {dict}. The following optional entries in {dict} are |
| 668 | supported: |
| 669 | buffer buffer name or number. See |bufname()|. |
| 670 | id sign identifier |
| 671 | If {dict} is not supplied, then all the signs in {group} are |
| 672 | removed. |
| 673 | |
| 674 | Returns 0 on success and -1 on failure. |
| 675 | |
| 676 | Examples: > |
| 677 | " Remove sign 10 from buffer a.vim |
| 678 | call sign_unplace('', {'buffer' : "a.vim", 'id' : 10}) |
| 679 | |
| 680 | " Remove sign 20 in group 'g1' from buffer 3 |
| 681 | call sign_unplace('g1', {'buffer' : 3, 'id' : 20}) |
| 682 | |
| 683 | " Remove all the signs in group 'g2' from buffer 10 |
| 684 | call sign_unplace('g2', {'buffer' : 10}) |
| 685 | |
| 686 | " Remove sign 30 in group 'g3' from all the buffers |
| 687 | call sign_unplace('g3', {'id' : 30}) |
| 688 | |
| 689 | " Remove all the signs placed in buffer 5 |
| 690 | call sign_unplace('*', {'buffer' : 5}) |
| 691 | |
| 692 | " Remove the signs in group 'g4' from all the buffers |
| 693 | call sign_unplace('g4') |
| 694 | |
| 695 | " Remove sign 40 from all the buffers |
| 696 | call sign_unplace('*', {'id' : 40}) |
| 697 | |
| 698 | " Remove all the placed signs from all the buffers |
| 699 | call sign_unplace('*') |
Bram Moolenaar | 93476fd | 2019-09-06 22:00:54 +0200 | [diff] [blame] | 700 | |
| 701 | < Can also be used as a |method|: > |
| 702 | GetSigngroup()->sign_unplace() |
Bram Moolenaar | ed997ad | 2019-07-21 16:42:00 +0200 | [diff] [blame] | 703 | < |
| 704 | sign_unplacelist({list}) *sign_unplacelist()* |
| 705 | Remove previously placed signs from one or more buffers. This |
| 706 | is similar to the |sign_unplace()| function. |
| 707 | |
| 708 | The {list} argument specifies the List of signs to remove. |
| 709 | Each list item is a dict with the following sign attributes: |
| 710 | buffer buffer name or number. For the accepted |
| 711 | values, see |bufname()|. If not specified, |
| 712 | then the specified sign is removed from all |
| 713 | the buffers. |
| 714 | group sign group name. If not specified or set to an |
| 715 | empty string, then the global sign group is |
| 716 | used. If set to '*', then all the groups |
| 717 | including the global group are used. |
| 718 | id sign identifier. If not specified, then all |
| 719 | the signs in the specified group are removed. |
| 720 | |
| 721 | Returns a List where an entry is set to 0 if the corresponding |
| 722 | sign was successfully removed or -1 on failure. |
| 723 | |
| 724 | Example: > |
| 725 | " Remove sign with id 10 from buffer a.vim and sign |
| 726 | " with id 20 from buffer b.vim |
| 727 | call sign_unplacelist([ |
| 728 | \ {'id' : 10, 'buffer' : "a.vim"}, |
| 729 | \ {'id' : 20, 'buffer' : 'b.vim'}, |
| 730 | \ ]) |
| 731 | < |
Bram Moolenaar | 93476fd | 2019-09-06 22:00:54 +0200 | [diff] [blame] | 732 | Can also be used as a |method|: > |
| 733 | GetSignlist()->sign_unplacelist() |
| 734 | < |
Bram Moolenaar | ed997ad | 2019-07-21 16:42:00 +0200 | [diff] [blame] | 735 | |
Bram Moolenaar | 91f84f6 | 2018-07-29 15:07:52 +0200 | [diff] [blame] | 736 | vim:tw=78:ts=8:noet:ft=help:norl: |