I'd like to be able to set additional marks to the already existing single lettered marks. Thus, I could solve two problemes I am currently facing:
the marks are set in a script and I don't want to destroy marks that were already set by the user of the script
I could set an unlimited number of marks so that I don't have to count them (I'd name them something like "script_mrk_" . s:mark_count
).
So, if expressed as function calls, I am probably looking for something
setPrivateMark(l:mark_name, l:line, l:pos)
and
let line_pos = getPrivateMark(l:mark_name)
Of course, the solution should be resistant to changes to the buffer above the mark after setting it with setPrivateMark
and before getPrivateMark(...)
.
Is there such a thing?
Vim only updates the position of its built-in marks on changes; if you need that functionality, you have to use those, and are limited to the number of existing marks.
There's no way around this; for simple user edits, you could hook into the CursorMovedI
event and adapt your recorded positions, but there's no way to hook Ex commands like :append
.
If you need a couple of marks for a plugin, it's good practice to allow the user to configure the marks used by the script (e.g. via a g:MyPlugin_UseMarks
variable); hardly anyone uses all the marks all the time, but different people have different preferences.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With