Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I create unlimited marks with vim?

Tags:

vim

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:

  1. 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

  2. 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?

like image 854
René Nyffenegger Avatar asked Apr 11 '13 12:04

René Nyffenegger


1 Answers

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.

like image 63
Ingo Karkat Avatar answered Oct 18 '22 22:10

Ingo Karkat