blob: d69355bb1587c3f306e9886e14a2539b4785b264 [file] [log] [blame]
Bram Moolenaarb7398fe2023-05-14 18:50:25 +01001*textprop.txt* For Vim version 9.0. Last change: 2023 Apr 23
Bram Moolenaar98aefe72018-12-13 22:20:09 +01002
3
4 VIM REFERENCE MANUAL by Bram Moolenaar
5
6
Bram Moolenaara6c27c42019-05-09 19:16:22 +02007Displaying text with properties attached. *textprop* *text-properties*
Bram Moolenaar98aefe72018-12-13 22:20:09 +01008
Bram Moolenaar98aefe72018-12-13 22:20:09 +01009
101. Introduction |text-prop-intro|
112. Functions |text-prop-functions|
Bram Moolenaard09091d2019-01-17 16:07:22 +0100123. When text changes |text-prop-changes|
Bram Moolenaar98aefe72018-12-13 22:20:09 +010013
14
Bram Moolenaar98aefe72018-12-13 22:20:09 +010015{not able to use text properties when the |+textprop| feature was
16disabled at compile time}
17
18==============================================================================
191. Introduction *text-prop-intro*
20
21Text properties can be attached to text in a buffer. They will move with the
22text: If lines are deleted or inserted the properties move with the text they
23are attached to. Also when inserting/deleting text in the line before the
24text property. And when inserting/deleting text inside the text property, it
25will increase/decrease in size.
26
27The main use for text properties is to highlight text. This can be seen as a
28replacement for syntax highlighting. Instead of defining patterns to match
29the text, the highlighting is set by a script, possibly using the output of an
30external parser. This only needs to be done once, not every time when
31redrawing the screen, thus can be much faster, after the initial cost of
32attaching the text properties.
33
34Text properties can also be used for other purposes to identify text. For
35example, add a text property on a function name, so that a search can be
36defined to jump to the next/previous function.
37
38A text property is attached at a specific line and column, and has a specified
39length. The property can span multiple lines.
40
41A text property has these fields:
42 "id" a number to be used as desired
43 "type" the name of a property type
44
45
46Property Types ~
47 *E971*
Bram Moolenaar664f3cf2019-12-07 16:03:51 +010048A text property normally has the name of a property type, which defines
Bram Moolenaar98aefe72018-12-13 22:20:09 +010049how to highlight the text. The property type can have these entries:
50 "highlight" name of the highlight group to use
Bram Moolenaar574ee7b2019-11-13 23:04:29 +010051 "combine" when omitted or TRUE the text property highlighting is
52 combined with any syntax highlighting; when FALSE the
Bram Moolenaarde24a872019-05-05 15:48:00 +020053 text property highlighting replaces the syntax
54 highlighting
Bram Moolenaar98aefe72018-12-13 22:20:09 +010055 "priority" when properties overlap, the one with the highest
56 priority will be used.
57 "start_incl" when TRUE inserts at the start position will be
58 included in the text property
Bram Moolenaar938ae282023-02-20 20:44:55 +000059 "end_incl" when TRUE inserts at the end position will be
Bram Moolenaar98aefe72018-12-13 22:20:09 +010060 included in the text property
61
62
63Example ~
64
65Suppose line 11 in a buffer has this text (excluding the indent):
66
67 The number 123 is smaller than 4567.
68
Bram Moolenaar4c05fa02019-01-01 15:32:17 +010069To highlight the numbers in this text: >
Bram Moolenaar98aefe72018-12-13 22:20:09 +010070 call prop_type_add('number', {'highlight': 'Constant'})
Bram Moolenaar9d87a372018-12-18 21:41:50 +010071 call prop_add(11, 12, {'length': 3, 'type': 'number'})
72 call prop_add(11, 32, {'length': 4, 'type': 'number'})
Bram Moolenaar98aefe72018-12-13 22:20:09 +010073
Bram Moolenaar4c05fa02019-01-01 15:32:17 +010074Try inserting or deleting lines above the text, you will see that the text
75properties stick to the text, thus the line number is adjusted as needed.
76
Bram Moolenaar98aefe72018-12-13 22:20:09 +010077Setting "start_incl" and "end_incl" is useful when white space surrounds the
78text, e.g. for a function name. Using false is useful when the text starts
79and/or ends with a specific character, such as the quote surrounding a string.
80
81 func FuncName(arg) ~
82 ^^^^^^^^ property with start_incl and end_incl set
83
84 var = "text"; ~
85 ^^^^^^ property with start_incl and end_incl not set
86
87Nevertheless, when text is inserted or deleted the text may need to be parsed
Bram Moolenaar9d87a372018-12-18 21:41:50 +010088and the text properties updated. But this can be done asynchronously.
Bram Moolenaar98aefe72018-12-13 22:20:09 +010089
Bram Moolenaar96f45c02019-10-26 19:53:45 +020090
91Internal error *E967*
92
93If you see E967, please report the bug. You can do this at Github:
94https://github.com/vim/vim/issues/new
95
Bram Moolenaar98aefe72018-12-13 22:20:09 +010096==============================================================================
972. Functions *text-prop-functions*
98
99Manipulating text property types:
100
101prop_type_add({name}, {props}) define a new property type
102prop_type_change({name}, {props}) change an existing property type
103prop_type_delete({name} [, {props}]) delete a property type
Bram Moolenaarcb80aa22020-10-26 21:12:46 +0100104prop_type_get({name} [, {props}]) get property type values
Bram Moolenaar98aefe72018-12-13 22:20:09 +0100105prop_type_list([{props}]) get list of property types
106
107
108Manipulating text properties:
109
Bram Moolenaar938ae282023-02-20 20:44:55 +0000110prop_add({lnum}, {col}, {props}) add a text property
Bram Moolenaarbe4e0162023-02-02 13:59:48 +0000111prop_add_list({props}, [{item}, ...])
Yegappan Lakshmananccfb7c62021-08-16 21:39:09 +0200112 add a text property at multiple
113 positions.
Bram Moolenaarc8c88492018-12-27 23:59:26 +0100114prop_clear({lnum} [, {lnum-end} [, {bufnr}]])
Bram Moolenaar98aefe72018-12-13 22:20:09 +0100115 remove all text properties
116prop_find({props} [, {direction}]) search for a text property
Bram Moolenaar938ae282023-02-20 20:44:55 +0000117prop_list({lnum} [, {props}]) text properties in {lnum}
Bram Moolenaarc8c88492018-12-27 23:59:26 +0100118prop_remove({props} [, {lnum} [, {lnum-end}]])
Bram Moolenaar98aefe72018-12-13 22:20:09 +0100119 remove a text property
120
Bram Moolenaared997ad2019-07-21 16:42:00 +0200121 *prop_add()* *E965*
122prop_add({lnum}, {col}, {props})
123 Attach a text property at position {lnum}, {col}. {col} is
124 counted in bytes, use one for the first column.
125 If {lnum} is invalid an error is given. *E966*
126 If {col} is invalid an error is given. *E964*
127
128 {props} is a dictionary with these fields:
Bram Moolenaarf396ce82022-08-23 18:39:37 +0100129 type name of the text property type
Bram Moolenaared997ad2019-07-21 16:42:00 +0200130 length length of text in bytes, can only be used
131 for a property that does not continue in
132 another line; can be zero
Bram Moolenaard2ea7cf2021-05-30 20:54:13 +0200133 end_lnum line number for the end of text (inclusive)
Bram Moolenaared997ad2019-07-21 16:42:00 +0200134 end_col column just after the text; not used when
135 "length" is present; when {col} and "end_col"
136 are equal, and "end_lnum" is omitted or equal
137 to {lnum}, this is a zero-width text property
138 bufnr buffer to add the property to; when omitted
139 the current buffer is used
Bram Moolenaarb17893a2020-03-14 08:19:51 +0100140 id user defined ID for the property; must be a
Bram Moolenaar7f9969c2022-07-25 18:13:54 +0100141 number, should be positive; when using "text"
142 then "id" must not be present and will be set
143 automatically to a negative number; otherwise
144 zero is used
Bram Moolenaar9712ff12022-09-18 13:04:22 +0100145 *E1305*
Bram Moolenaar9fbdbb82022-09-27 17:30:34 +0100146 text text to be displayed before {col}, or
147 above/below the line if {col} is zero; prepend
148 and/or append spaces for padding with
149 highlighting; cannot be used with "length",
Bram Moolenaarb59ae592022-11-23 23:46:31 +0000150 "end_lnum" and "end_col"
151 See |virtual-text| for more information.
Bram Moolenaar938ae282023-02-20 20:44:55 +0000152 *E1294*
Bram Moolenaarf396ce82022-08-23 18:39:37 +0100153 text_align when "text" is present and {col} is zero;
Bram Moolenaarb7963df2022-07-31 17:12:43 +0100154 specifies where to display the text:
155 after after the end of the line
Bram Moolenaare1f3fd12022-08-15 18:51:32 +0100156 right right aligned in the window (unless
157 the text wraps to the next screen
158 line)
Bram Moolenaarb7963df2022-07-31 17:12:43 +0100159 below in the next screen line
Bram Moolenaar04e0ed12022-09-10 20:00:56 +0100160 above just above the line
Bram Moolenaare1f3fd12022-08-15 18:51:32 +0100161 When omitted "after" is used. Only one
Bram Moolenaarf396ce82022-08-23 18:39:37 +0100162 "right" property can fit in each line, if
Bram Moolenaar9712ff12022-09-18 13:04:22 +0100163 there are two or more these will go in a
Bram Moolenaarf396ce82022-08-23 18:39:37 +0100164 separate line (still right aligned).
165 text_padding_left *E1296*
166 used when "text" is present and {col} is zero;
167 padding between the end of the text line
Bram Moolenaarb7398fe2023-05-14 18:50:25 +0100168 (leftmost column for "above" and "below") and
169 the virtual text, not highlighted
Bram Moolenaarb7963df2022-07-31 17:12:43 +0100170 text_wrap when "text" is present and {col} is zero,
171 specifies what happens if the text doesn't
172 fit:
173 wrap wrap the text to the next line
174 truncate truncate the text to make it fit
Bram Moolenaar938ae282023-02-20 20:44:55 +0000175 When omitted "truncate" is used.
Bram Moolenaar3c053a12022-10-16 13:11:12 +0100176 Note that this applies to the individual text
177 property, the 'wrap' option sets the overall
178 behavior
Bram Moolenaared997ad2019-07-21 16:42:00 +0200179 All fields except "type" are optional.
180
181 It is an error when both "length" and "end_lnum" or "end_col"
182 are given. Either use "length" or "end_col" for a property
183 within one line, or use "end_lnum" and "end_col" for a
184 property that spans more than one line.
185 When neither "length" nor "end_col" are given the property
Bram Moolenaarbc93ceb2020-02-26 13:36:21 +0100186 will be zero-width. That means it will move with the text, as
187 a kind of mark. One character will be highlighted, if the
188 type specifies highlighting.
Bram Moolenaared997ad2019-07-21 16:42:00 +0200189 The property can end exactly at the last character of the
190 text, or just after it. In the last case, if text is appended
191 to the line, the text property size will increase, also when
192 the property type does not have "end_incl" set.
193
194 "type" will first be looked up in the buffer the property is
195 added to. When not found, the global property types are used.
196 If not found an error is given.
Bram Moolenaar7f9969c2022-07-25 18:13:54 +0100197 *virtual-text*
Bram Moolenaarb7963df2022-07-31 17:12:43 +0100198 When "text" is used and the column is non-zero then this text
Bram Moolenaar9fbdbb82022-09-27 17:30:34 +0100199 will be displayed at the specified start location of the text
200 property. The text of the buffer line will be shifted to make
201 room. This is called "virtual text".
202 When the column is zero the virtual text will appear above,
203 after or below the buffer text. The "text_align" and
204 "text_wrap" arguments determine how it is displayed.
205 To separate the virtual text from the buffer text prepend
206 and/or append spaces to the "text" field or use the
207 "text_padding_left" value.
208
209 Make sure to use a highlight that makes clear to the user that
210 this is virtual text, otherwise it will be very confusing that
211 the text cannot be edited. When using "above" you need to
212 make clear this text belongs to the text line below it, when
213 using "below" you need to make sure it belongs to the text
214 line above it.
215
Bram Moolenaar7f9969c2022-07-25 18:13:54 +0100216 The text will be displayed but it is not part of the actual
217 buffer line, the cursor cannot be placed on it. A mouse click
218 in the text will move the cursor to the first character after
Bram Moolenaarb7963df2022-07-31 17:12:43 +0100219 the text, or the last character of the line.
Bram Moolenaare1f3fd12022-08-15 18:51:32 +0100220 Any Tab and other control character in the text will be
221 changed to a space (Rationale: otherwise the size of the text
222 is difficult to compute).
Bram Moolenaarf1dcd142022-12-31 15:30:45 +0000223 A negative "id" will be chosen and is returned.
224
225 Before text properties with text were supported it was
226 possible to use a negative "id", even though this was very
227 rare. Now that negative "id"s are reserved for text
228 properties with text an error is given when using a negative
229 "id". When a text property with text already exists using a
230 negative "id" results in *E1293* . If a negative "id" was
231 used and later a text property with text is added results in
232 *E1339* .
Bram Moolenaared997ad2019-07-21 16:42:00 +0200233
Bram Moolenaara5a78822019-09-04 21:57:18 +0200234 Can also be used as a |method|: >
235 GetLnum()->prop_add(col, props)
Yegappan Lakshmanan820d5522021-09-17 21:07:35 +0200236<
Yegappan Lakshmananccfb7c62021-08-16 21:39:09 +0200237 *prop_add_list()*
Bram Moolenaard93009e2022-10-13 14:35:24 +0100238prop_add_list({props}, [{item}, ...])
Yegappan Lakshmananccfb7c62021-08-16 21:39:09 +0200239 Similar to prop_add(), but attaches a text property at
240 multiple positions in a buffer.
241
242 {props} is a dictionary with these fields:
243 bufnr buffer to add the property to; when omitted
244 the current buffer is used
245 id user defined ID for the property; must be a
246 number; when omitted zero is used
247 type name of the text property type
248 All fields except "type" are optional.
249
Bram Moolenaard93009e2022-10-13 14:35:24 +0100250 The second argument is a List of items, where each {item} is a
251 list that specifies the starting and ending position of the
252 text: [{lnum}, {col}, {end-lnum}, {end-col}]
253 or: [{lnum}, {col}, {end-lnum}, {end-col}, {id}]
254
255 The first two items {lnum} and {col} specify the starting
256 position of the text where the property will be attached.
257 The next two items {end-lnum} and {end-col} specify the
258 position just after the text.
259 An optional fifth item {id} can be used to give a different ID
260 to a property. When omitted the ID from {props} is used,
261 falling back to zero if none are present.
Yegappan Lakshmananccfb7c62021-08-16 21:39:09 +0200262
Bram Moolenaar7f9969c2022-07-25 18:13:54 +0100263 It is not possible to add a text property with a "text" field
264 here.
265
Bram Moolenaarbe4e0162023-02-02 13:59:48 +0000266 Example: >
Yegappan Lakshmananccfb7c62021-08-16 21:39:09 +0200267 call prop_add_list(#{type: 'MyProp', id: 2},
268 \ [[1, 4, 1, 7],
269 \ [1, 15, 1, 20],
270 \ [2, 30, 3, 30]]
Bram Moolenaarbe4e0162023-02-02 13:59:48 +0000271<
Yegappan Lakshmananccfb7c62021-08-16 21:39:09 +0200272 Can also be used as a |method|: >
273 GetProp()->prop_add_list([[1, 1, 1, 2], [1, 4, 1, 8]])
274
Bram Moolenaared997ad2019-07-21 16:42:00 +0200275
276prop_clear({lnum} [, {lnum-end} [, {props}]]) *prop_clear()*
277 Remove all text properties from line {lnum}.
278 When {lnum-end} is given, remove all text properties from line
279 {lnum} to {lnum-end} (inclusive).
280
281 When {props} contains a "bufnr" item use this buffer,
282 otherwise use the current buffer.
283
Bram Moolenaara5a78822019-09-04 21:57:18 +0200284 Can also be used as a |method|: >
285 GetLnum()->prop_clear()
286<
Bram Moolenaared997ad2019-07-21 16:42:00 +0200287 *prop_find()*
288prop_find({props} [, {direction}])
Bram Moolenaared997ad2019-07-21 16:42:00 +0200289 Search for a text property as specified with {props}:
290 id property with this ID
291 type property with this type name
Bram Moolenaar24f21fd2021-03-27 22:07:29 +0100292 both "id" and "type" must both match
Bram Moolenaared997ad2019-07-21 16:42:00 +0200293 bufnr buffer to search in; when present a
294 start position with "lnum" and "col"
295 must be given; when omitted the
296 current buffer is used
297 lnum start in this line (when omitted start
298 at the cursor)
299 col start at this column (when omitted
300 and "lnum" is given: use column 1,
301 otherwise start at the cursor)
302 skipstart do not look for a match at the start
303 position
304
Bram Moolenaar24f21fd2021-03-27 22:07:29 +0100305 A property matches when either "id" or "type" matches.
Bram Moolenaared997ad2019-07-21 16:42:00 +0200306 {direction} can be "f" for forward and "b" for backward. When
307 omitted forward search is performed.
308
309 If a match is found then a Dict is returned with the entries
310 as with prop_list(), and additionally an "lnum" entry.
311 If no match is found then an empty Dict is returned.
312
Bram Moolenaared997ad2019-07-21 16:42:00 +0200313
314prop_list({lnum} [, {props}]) *prop_list()*
Yegappan Lakshmanane0216622021-11-23 11:46:32 +0000315 Returns a List with all the text properties in line {lnum}.
Bram Moolenaared997ad2019-07-21 16:42:00 +0200316
Yegappan Lakshmanane0216622021-11-23 11:46:32 +0000317 The following optional items are supported in {props}:
318 bufnr use this buffer instead of the current buffer
319 end_lnum return text properties in all the lines
320 between {lnum} and {end_lnum} (inclusive).
321 A negative value is used as an offset from the
322 last buffer line; -1 refers to the last buffer
323 line.
324 types List of property type names. Return only text
325 properties that match one of the type names.
326 ids List of property identifiers. Return only text
327 properties with one of these identifiers.
Bram Moolenaared997ad2019-07-21 16:42:00 +0200328
329 The properties are ordered by starting column and priority.
330 Each property is a Dict with these entries:
Yegappan Lakshmanane0216622021-11-23 11:46:32 +0000331 lnum starting line number. Present only when
332 returning text properties between {lnum} and
333 {end_lnum}.
Bram Moolenaared997ad2019-07-21 16:42:00 +0200334 col starting column
335 length length in bytes, one more if line break is
336 included
337 id property ID
338 type name of the property type, omitted if
339 the type was deleted
Martin Tournoije2390c72021-07-28 13:30:16 +0200340 type_bufnr buffer number for which this type was defined;
341 0 if the type is global
Bram Moolenaared997ad2019-07-21 16:42:00 +0200342 start when TRUE property starts in this line
343 end when TRUE property ends in this line
344
345 When "start" is zero the property started in a previous line,
346 the current one is a continuation.
347 When "end" is zero the property continues in the next line.
348 The line break after this line is included.
349
Yegappan Lakshmanane0216622021-11-23 11:46:32 +0000350 Returns an empty list on error.
351
352 Examples:
353 " get text properties placed in line 5
354 echo prop_list(5)
355 " get text properties placed in line 20 in buffer 4
356 echo prop_list(20, {'bufnr': 4})
357 " get all the text properties between line 1 and 20
358 echo prop_list(1, {'end_lnum': 20})
359 " get all the text properties of type 'myprop'
360 echo prop_list(1, {'types': ['myprop'],
361 \ 'end_lnum': -1})
362 " get all the text properties of type 'prop1' or 'prop2'
363 echo prop_list(1, {'types': ['prop1', 'prop2'],
364 \ 'end_lnum': -1})
365 " get all the text properties with ID 8
366 echo prop_list(1, {'ids': [8], 'end_lnum': line('$')})
367 " get all the text properties with ID 10 and 20
368 echo prop_list(1, {'ids': [10, 20], 'end_lnum': -1})
369 " get text properties with type 'myprop' and ID 100
370 " in buffer 4.
371 echo prop_list(1, {'bufnr': 4, 'types': ['myprop'],
372 \ 'ids': [100], 'end_lnum': -1})
373
Bram Moolenaara5a78822019-09-04 21:57:18 +0200374 Can also be used as a |method|: >
375 GetLnum()->prop_list()
376<
Bram Moolenaar7ff78462020-07-10 22:00:53 +0200377 *prop_remove()* *E968* *E860*
Bram Moolenaared997ad2019-07-21 16:42:00 +0200378prop_remove({props} [, {lnum} [, {lnum-end}]])
379 Remove a matching text property from line {lnum}. When
380 {lnum-end} is given, remove matching text properties from line
381 {lnum} to {lnum-end} (inclusive).
382 When {lnum} is omitted remove matching text properties from
Bram Moolenaard2ea7cf2021-05-30 20:54:13 +0200383 all lines (this requires going over all lines, thus will be a
384 bit slow for a buffer with many lines).
Bram Moolenaared997ad2019-07-21 16:42:00 +0200385
386 {props} is a dictionary with these fields:
387 id remove text properties with this ID
388 type remove text properties with this type name
Bram Moolenaarfd999452022-08-24 18:30:14 +0100389 types remove text properties with type names in this
390 List
391 both "id" and "type"/"types" must both match
Bram Moolenaared997ad2019-07-21 16:42:00 +0200392 bufnr use this buffer instead of the current one
393 all when TRUE remove all matching text properties,
394 not just the first one
Bram Moolenaarfd999452022-08-24 18:30:14 +0100395 Only one of "type" and "types" may be supplied. *E1295*
396
397 A property matches when either "id" or one of the supplied
398 types matches.
Bram Moolenaared997ad2019-07-21 16:42:00 +0200399 If buffer "bufnr" does not exist you get an error message.
400 If buffer "bufnr" is not loaded then nothing happens.
401
402 Returns the number of properties that were removed.
403
Bram Moolenaara5a78822019-09-04 21:57:18 +0200404 Can also be used as a |method|: >
405 GetProps()->prop_remove()
406
Bram Moolenaared997ad2019-07-21 16:42:00 +0200407
408prop_type_add({name}, {props}) *prop_type_add()* *E969* *E970*
409 Add a text property type {name}. If a property type with this
Bram Moolenaar06fe74a2019-08-31 16:20:32 +0200410 name already exists an error is given. Nothing is returned.
Bram Moolenaared997ad2019-07-21 16:42:00 +0200411 {props} is a dictionary with these optional fields:
412 bufnr define the property only for this buffer; this
413 avoids name collisions and automatically
414 clears the property types when the buffer is
415 deleted.
416 highlight name of highlight group to use
417 priority when a character has multiple text
418 properties the one with the highest priority
419 will be used; negative values can be used, the
420 default priority is zero
Bram Moolenaardad44732021-03-31 20:07:33 +0200421 combine when omitted or TRUE combine the highlight
422 with any syntax highlight; when FALSE syntax
Bram Moolenaared997ad2019-07-21 16:42:00 +0200423 highlight will not be used
Bram Moolenaarf4ba8bc2022-08-05 17:05:04 +0100424 override when TRUE the highlight overrides any other,
425 including 'cursorline' and Visual
Bram Moolenaared997ad2019-07-21 16:42:00 +0200426 start_incl when TRUE inserts at the start position will
427 be included in the text property
428 end_incl when TRUE inserts at the end position will be
429 included in the text property
430
Bram Moolenaara5a78822019-09-04 21:57:18 +0200431 Can also be used as a |method|: >
432 GetPropName()->prop_type_add(props)
Bram Moolenaared997ad2019-07-21 16:42:00 +0200433
434prop_type_change({name}, {props}) *prop_type_change()*
435 Change properties of an existing text property type. If a
436 property with this name does not exist an error is given.
437 The {props} argument is just like |prop_type_add()|.
438
Bram Moolenaara5a78822019-09-04 21:57:18 +0200439 Can also be used as a |method|: >
440 GetPropName()->prop_type_change(props)
Bram Moolenaared997ad2019-07-21 16:42:00 +0200441
442prop_type_delete({name} [, {props}]) *prop_type_delete()*
443 Remove the text property type {name}. When text properties
444 using the type {name} are still in place, they will not have
445 an effect and can no longer be removed by name.
446
447 {props} can contain a "bufnr" item. When it is given, delete
448 a property type from this buffer instead of from the global
449 property types.
450
451 When text property type {name} is not found there is no error.
452
Bram Moolenaara5a78822019-09-04 21:57:18 +0200453 Can also be used as a |method|: >
454 GetPropName()->prop_type_delete()
Bram Moolenaared997ad2019-07-21 16:42:00 +0200455
Bram Moolenaarcb80aa22020-10-26 21:12:46 +0100456prop_type_get({name} [, {props}]) *prop_type_get()*
Bram Moolenaared997ad2019-07-21 16:42:00 +0200457 Returns the properties of property type {name}. This is a
458 dictionary with the same fields as was given to
459 prop_type_add().
460 When the property type {name} does not exist, an empty
461 dictionary is returned.
462
463 {props} can contain a "bufnr" item. When it is given, use
464 this buffer instead of the global property types.
465
Bram Moolenaara5a78822019-09-04 21:57:18 +0200466 Can also be used as a |method|: >
467 GetPropName()->prop_type_get()
Bram Moolenaared997ad2019-07-21 16:42:00 +0200468
469prop_type_list([{props}]) *prop_type_list()*
470 Returns a list with all property type names.
471
472 {props} can contain a "bufnr" item. When it is given, use
473 this buffer instead of the global property types.
474
Bram Moolenaared997ad2019-07-21 16:42:00 +0200475
Bram Moolenaard09091d2019-01-17 16:07:22 +0100476==============================================================================
4773. When text changes *text-prop-changes*
478
479Vim will do its best to keep the text properties on the text where it was
480attached. When inserting or deleting text the properties after the change
481will move accordingly.
482
483When text is deleted and a text property no longer includes any text, it is
484deleted. However, a text property that was defined as zero-width will remain,
485unless the whole line is deleted.
Bram Moolenaar30e9b3c2019-09-07 16:24:12 +0200486 *E275*
Bram Moolenaar45311b52019-08-13 22:27:32 +0200487When a buffer is unloaded, all the text properties are gone. There is no way
488to store the properties in a file. You can only re-create them. When a
489buffer is hidden the text is preserved and so are the text properties. It is
490not possible to add text properties to an unloaded buffer.
Bram Moolenaard09091d2019-01-17 16:07:22 +0100491
492When using replace mode, the text properties stay on the same character
493positions, even though the characters themselves change.
494
Bram Moolenaar68e65602019-05-26 21:33:31 +0200495To update text properties after the text was changed, install a callback with
496`listener_add()`. E.g, if your plugin does spell checking, you can have the
497callback update spelling mistakes in the changed text. Vim will move the
498properties below the changed text, so that they still highlight the same text,
499thus you don't need to update these.
500
Bram Moolenaard09091d2019-01-17 16:07:22 +0100501
Bram Moolenaarbc93ceb2020-02-26 13:36:21 +0100502Text property columns are not updated or copied: ~
Bram Moolenaard09091d2019-01-17 16:07:22 +0100503
504- When setting the line with |setline()| or through an interface, such as Lua,
Bram Moolenaara6c27c42019-05-09 19:16:22 +0200505 Tcl or Python. Vim does not know what text got inserted or deleted.
Bram Moolenaarbc93ceb2020-02-26 13:36:21 +0100506- With a command like `:move`, which takes a line of text out of context.
Bram Moolenaard09091d2019-01-17 16:07:22 +0100507
Bram Moolenaar98aefe72018-12-13 22:20:09 +0100508
509 vim:tw=78:ts=8:noet:ft=help:norl: