sign.txt 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. *sign.txt* Nvim
  2. VIM REFERENCE MANUAL by Gordon Prieur
  3. and Bram Moolenaar
  4. Sign Support Features *sign-support*
  5. Type |gO| to see the table of contents.
  6. ==============================================================================
  7. 1. Introduction *sign-intro* *signs* *gutter*
  8. When a debugger or other IDE tool is driving an editor it needs to be able
  9. to give specific highlights which quickly tell the user useful information
  10. about the file. One example of this would be a debugger which had an icon
  11. in the left-hand column denoting a breakpoint. Another example might be an
  12. arrow representing the Program Counter (PC). The sign features allow both
  13. placement of a sign, or icon, in the left-hand side of the window and
  14. definition of a highlight which will be applied to that line. Displaying the
  15. sign as an image is most likely only feasible in gvim (although Sun
  16. Microsystem's dtterm does support this it's the only terminal emulator I know
  17. of which does). A text sign and the highlight should be feasible in any color
  18. terminal emulator.
  19. Signs and highlights are not useful just for debuggers. There are plugins
  20. that use signs to mark build errors or display version control status.
  21. There are two steps in using signs:
  22. 1. Define the sign. This specifies the image, text and highlighting. For
  23. example, you can define a "break" sign with an image of a stop roadsign and
  24. text "!!".
  25. 2. Place the sign. This specifies the file and line number where the sign is
  26. displayed. A defined sign can be placed several times in different lines
  27. and files.
  28. *sign-column*
  29. When signs are defined for a file, Vim will automatically add a column of two
  30. characters to display them in. When the last sign is unplaced the column
  31. disappears again. This behavior can be changed with the 'signcolumn' option.
  32. The color of the column is set with the SignColumn highlight group
  33. |hl-SignColumn|. Example to set the color: >
  34. :highlight SignColumn guibg=darkgrey
  35. <
  36. If 'cursorline' is enabled, then the CursorLineSign highlight group is used
  37. |hl-CursorLineSign|.
  38. *sign-identifier*
  39. Each placed sign is identified by a number called the sign identifier. This
  40. identifier is used to jump to the sign or to remove the sign. The identifier
  41. is assigned when placing the sign using the |:sign-place| command or the
  42. |sign_place()| function. Each sign identifier should be a unique number (per
  43. buffer). Placing the same identifier twice will move the previously placed
  44. sign. The |sign_place()| function can be called with a zero sign identifier to
  45. allocate the next available identifier.
  46. *sign-group*
  47. Each placed sign can be assigned to either the global group or a named group.
  48. When placing a sign, if a group name is not supplied, or an empty string is
  49. used, then the sign is placed in the global group. Otherwise the sign is
  50. placed in the named group. The sign identifier is unique within a group. The
  51. sign group allows Vim plugins to use unique signs without interfering with
  52. other plugins using signs.
  53. *sign-priority*
  54. Each placed sign is assigned a priority value independently of the sign group.
  55. The default priority for a sign is 10, this value can be changed for different
  56. signs by specifying a different value at definition time. When multiple signs
  57. that each have an icon or text are placed on the same line, signs are ordered
  58. with decreasing priority from left to right, up until the maximum width set in
  59. 'signcolumn'. Low priority signs that do not fit are hidden. Highest priority
  60. signs with highlight attributes are always shown.
  61. When the line on which the sign is placed is deleted, the sign is removed along
  62. with it.
  63. ==============================================================================
  64. 2. Commands *sign-commands* *:sig* *:sign*
  65. Here is an example that places a sign "piet", displayed with the text ">>", in
  66. line 23 of the current file: >
  67. :sign define piet text=>> texthl=Search
  68. :exe ":sign place 2 line=23 name=piet file=" .. expand("%:p")
  69. And here is the command to delete it again: >
  70. :sign unplace 2
  71. Note that the ":sign" command cannot be followed by another command or a
  72. comment. If you do need that, use the |:execute| command.
  73. DEFINING A SIGN. *:sign-define* *E255* *E160* *E612*
  74. See |sign_define()| for the equivalent Vim script function.
  75. :sign define {name} {argument}...
  76. Define a new sign or set attributes for an existing sign.
  77. The {name} can either be a number (all digits) or a name
  78. starting with a non-digit. Leading zeros are ignored, thus
  79. "0012", "012" and "12" are considered the same name.
  80. About 120 different signs can be defined.
  81. Accepted arguments:
  82. icon={bitmap}
  83. Define the file name where the bitmap can be found. Should be
  84. a full path. The bitmap should fit in the place of two
  85. characters. This is not checked. If the bitmap is too big it
  86. will cause redraw problems.
  87. toolkit supports ~
  88. Win32 .bmp, .ico, .cur
  89. priority={prio}
  90. Default priority for the sign, see |sign-priority|.
  91. linehl={group}
  92. Highlighting group used for the whole line the sign is placed
  93. in. Most useful is defining a background color.
  94. numhl={group}
  95. Highlighting group used for the line number on the line where
  96. the sign is placed. Overrides |hl-LineNr|, |hl-LineNrAbove|,
  97. |hl-LineNrBelow|, and |hl-CursorLineNr|.
  98. text={text} *E239*
  99. Define the text that is displayed when there is no icon or the
  100. GUI is not being used. Only printable characters are allowed
  101. and they must occupy one or two display cells.
  102. texthl={group}
  103. Highlighting group used for the text item.
  104. culhl={group}
  105. Highlighting group used for the text item when the cursor is
  106. on the same line as the sign and 'cursorline' is enabled.
  107. Example: >
  108. :sign define MySign text=>> texthl=Search linehl=DiffText
  109. <
  110. DELETING A SIGN *:sign-undefine* *E155*
  111. See |sign_undefine()| for the equivalent Vim script function.
  112. :sign undefine {name}
  113. Deletes a previously defined sign. If signs with this {name}
  114. are still placed this will cause trouble.
  115. Example: >
  116. :sign undefine MySign
  117. <
  118. LISTING SIGNS *:sign-list* *E156*
  119. See |sign_getdefined()| for the equivalent Vim script function.
  120. :sign list Lists all defined signs and their attributes.
  121. :sign list {name}
  122. Lists one defined sign and its attributes.
  123. PLACING SIGNS *:sign-place* *E158*
  124. See |sign_place()| for the equivalent Vim script function.
  125. :sign place {id} line={lnum} name={name} file={fname}
  126. Place sign defined as {name} at line {lnum} in file {fname}.
  127. *:sign-fname*
  128. The file {fname} must already be loaded in a buffer. The
  129. exact file name must be used, wildcards, $ENV and ~ are not
  130. expanded, white space must not be escaped. Trailing white
  131. space is ignored.
  132. The sign is remembered under {id}, this can be used for
  133. further manipulation. {id} must be a number. Placing the
  134. same {id} multiple times will move the sign.
  135. The following optional sign attributes can be specified before
  136. "file=":
  137. group={group} Place sign in sign group {group}
  138. priority={prio} Assign priority {prio} to sign
  139. By default, the sign is placed in the global sign group.
  140. By default, the sign is assigned a default priority of 10,
  141. unless specified otherwise by the sign definition. To assign a
  142. different priority value, use "priority={prio}" to specify a
  143. value. The priority is used to determine the sign that is
  144. displayed when multiple signs are placed on the same line.
  145. Examples: >
  146. :sign place 5 line=3 name=sign1 file=a.py
  147. :sign place 6 group=g2 line=2 name=sign2 file=x.py
  148. :sign place 9 group=g2 priority=50 line=5
  149. \ name=sign1 file=a.py
  150. <
  151. :sign place {id} line={lnum} name={name} [buffer={nr}]
  152. Same, but use buffer {nr}. If the buffer argument is not
  153. given, place the sign in the current buffer.
  154. Example: >
  155. :sign place 10 line=99 name=sign3
  156. :sign place 10 line=99 name=sign3 buffer=3
  157. <
  158. *E885*
  159. :sign place {id} name={name} file={fname}
  160. Change the placed sign {id} in file {fname} to use the defined
  161. sign {name}. See remark above about {fname} |:sign-fname|.
  162. This can be used to change the displayed sign without moving
  163. it (e.g., when the debugger has stopped at a breakpoint).
  164. The optional "group={group}" attribute can be used before
  165. "file=" to select a sign in a particular group. The optional
  166. "priority={prio}" attribute can be used to change the priority
  167. of an existing sign.
  168. Example: >
  169. :sign place 23 name=sign1 file=/path/to/edit.py
  170. <
  171. :sign place {id} name={name} [buffer={nr}]
  172. Same, but use buffer {nr}. If the buffer argument is not
  173. given, use the current buffer.
  174. Example: >
  175. :sign place 23 name=sign1
  176. :sign place 23 name=sign1 buffer=7
  177. <
  178. REMOVING SIGNS *:sign-unplace* *E159*
  179. See |sign_unplace()| for the equivalent Vim script function.
  180. :sign unplace {id} file={fname}
  181. Remove the previously placed sign {id} from file {fname}.
  182. See remark above about {fname} |:sign-fname|.
  183. :sign unplace {id} group={group} file={fname}
  184. Same but remove the sign {id} in sign group {group}.
  185. :sign unplace {id} group=* file={fname}
  186. Same but remove the sign {id} from all the sign groups.
  187. :sign unplace * file={fname}
  188. Remove all placed signs in file {fname}.
  189. :sign unplace * group={group} file={fname}
  190. Remove all placed signs in group {group} from file {fname}.
  191. :sign unplace * group=* file={fname}
  192. Remove all placed signs in all the groups from file {fname}.
  193. :sign unplace {id} buffer={nr}
  194. Remove the previously placed sign {id} from buffer {nr}.
  195. :sign unplace {id} group={group} buffer={nr}
  196. Remove the previously placed sign {id} in group {group} from
  197. buffer {nr}.
  198. :sign unplace {id} group=* buffer={nr}
  199. Remove the previously placed sign {id} in all the groups from
  200. buffer {nr}.
  201. :sign unplace * buffer={nr}
  202. Remove all placed signs in buffer {nr}.
  203. :sign unplace * group={group} buffer={nr}
  204. Remove all placed signs in group {group} from buffer {nr}.
  205. :sign unplace * group=* buffer={nr}
  206. Remove all placed signs in all the groups from buffer {nr}.
  207. :sign unplace {id}
  208. Remove the previously placed sign {id} from all files it
  209. appears in.
  210. :sign unplace {id} group={group}
  211. Remove the previously placed sign {id} in group {group} from
  212. all files it appears in.
  213. :sign unplace {id} group=*
  214. Remove the previously placed sign {id} in all the groups from
  215. all the files it appears in.
  216. :sign unplace *
  217. Remove all placed signs in the global group from all the files.
  218. :sign unplace * group={group}
  219. Remove all placed signs in group {group} from all the files.
  220. :sign unplace * group=*
  221. Remove all placed signs in all the groups from all the files.
  222. :sign unplace
  223. Remove a placed sign at the cursor position. If multiple signs
  224. are placed in the line, then only one is removed.
  225. :sign unplace group={group}
  226. Remove a placed sign in group {group} at the cursor
  227. position.
  228. :sign unplace group=*
  229. Remove a placed sign in any group at the cursor position.
  230. LISTING PLACED SIGNS *:sign-place-list*
  231. See |sign_getplaced()| for the equivalent Vim script function.
  232. :sign place file={fname}
  233. List signs placed in file {fname}.
  234. See remark above about {fname} |:sign-fname|.
  235. :sign place group={group} file={fname}
  236. List signs in group {group} placed in file {fname}.
  237. :sign place group=* file={fname}
  238. List signs in all the groups placed in file {fname}.
  239. :sign place buffer={nr}
  240. List signs placed in buffer {nr}.
  241. :sign place group={group} buffer={nr}
  242. List signs in group {group} placed in buffer {nr}.
  243. :sign place group=* buffer={nr}
  244. List signs in all the groups placed in buffer {nr}.
  245. :sign place List placed signs in the global group in all files.
  246. :sign place group={group}
  247. List placed signs with sign group {group} in all files.
  248. :sign place group=*
  249. List placed signs in all sign groups in all files.
  250. JUMPING TO A SIGN *:sign-jump* *E157*
  251. See |sign_jump()| for the equivalent Vim script function.
  252. :sign jump {id} file={fname}
  253. Open the file {fname} or jump to the window that contains
  254. {fname} and position the cursor at sign {id}.
  255. See remark above about {fname} |:sign-fname|.
  256. If the file isn't displayed in window and the current file can
  257. not be |abandon|ed this fails.
  258. :sign jump {id} group={group} file={fname}
  259. Same but jump to the sign in group {group}
  260. :sign jump {id} [buffer={nr}] *E934*
  261. Same, but use buffer {nr}. This fails if buffer {nr} does not
  262. have a name. If the buffer argument is not given, use the
  263. current buffer.
  264. :sign jump {id} group={group} [buffer={nr}]
  265. Same but jump to the sign in group {group}
  266. ==============================================================================
  267. 3. Functions *sign-functions-details*
  268. See:
  269. - |sign_define()|
  270. - |sign_getdefined()|
  271. - |sign_getplaced()|
  272. - |sign_jump()|
  273. - |sign_place()|
  274. - |sign_placelist()|
  275. - |sign_undefine()|
  276. - |sign_unplace()|
  277. - |sign_unplacelist()|
  278. vim:tw=78:ts=8:noet:ft=help:norl: