Possible marks are {a-zA-Z'}. Is there a mechanism to set more of them? The goal is to track certain (modifiable) lines and detect when they are deleted (e.g. with dd).


I am building a UI to manipulate pairs of UUID and strings. A subset of pairs is loaded onto the buffer for editing. Only strings (on each line) are meant to be edited and UUID should be hidden. One method is to place UUID along with the string and conceal it. But UUIDs can get unintentionally deleted with concealcursor=nvic while changing the string, e.g. with cc. Marks will allow the addition, deletion and modification of string lines without losing track. Ideally, the plugin will create a mark for a line with its UUID as identifier (instead of {a-zA-Z'}).

Effectively I want to "annotate" a line with a piece of text that stays consistent after addition/deletion of lines above it and gets removed along with the line on deletion.

  • 2
    Can you provide some more detail on this tracking? How do you use the information, for instance. (The details might inform an alternative to using marks. This may be an XY problem )
    – B Layer
    Commented Jun 12, 2021 at 7:23
  • 3
    ...stays consistent after addition/deletion of lines above it and gets removed along with the line on deletion - That's pretty much the description of "text properties", introduced in Vim 8.2. :h textprop. Now you wouldn't annotate with a piece of text but something more like a highlight. This may be adaptable to your purposes, though.
    – B Layer
    Commented Jun 12, 2021 at 9:47
  • 1
    I mean you wouldn't annotate with buffer-located text. A text property has an associated id and type field (analagous to a highlight group's style). They're not visible...but that's what you want so....
    – B Layer
    Commented Jun 12, 2021 at 9:53
  • 1
    I should point out that the description of text properties "id" field is "a number to be used as desired". "Used as desired": good, "id": good, "number": well, if your UUIDs are alphanumeric then "not so good"...you can't just pop 'em in there. But should be simple enough to map numbers to alphanumerics.
    – B Layer
    Commented Jun 12, 2021 at 10:12
  • 1
    @BLayer Thank you so much. textprop led to find a more direct analogue in nvim as api-extended-marks. You saved the day when I was about to reimplement marks.
    – tejasvi
    Commented Jun 12, 2021 at 10:41

1 Answer 1


The number of marks is hard-coded in Vim, and you can't get any more without modifying the source. – Martin Tournoij

However, an advanced alternative exists in form of :h textprop in Vim and :h api-extended-marks in Neovim.

In Neovim, marks can be set using nvim_buf_set_extmark(*args) which returns unique id for the mark. E.g. Creating mark on line 0 and column 2.

let g:mark_ns = nvim_create_namespace('example')
let g:mark_id = nvim_buf_set_extmark(0, g:mark_ns, 0, 2, {})

We can get the mark by its id:

echo nvim_buf_get_extmark_by_id(0, g:mark_ns, g:mark_id)
=> [0, 2]
  • 2
    @BLayer Added! Though in the end I went with a hacky conceal route. Extmarks were unreliable for my use case since they are not removed on line deletion (unlike conventional marks)
    – tejasvi
    Commented Jul 18, 2021 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.