Can I create unlimited tags using vim?

I would like to be able to set additional tags for existing single point tags. Thus, I could solve two problems that I am facing now:

  • labels are set in the script, and I do not want to destroy labels that have already been set by the user script

  • I could set an unlimited number of labels so that I didn't have to count them (I would call them something like "script_mrk_" . s:mark_count ).

So, if expressed as function calls, I was 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 in the buffer above the label after setting it using setPrivateMark and before getPrivateMark(...) .

Is there such a thing?

+4
source share
2 answers

Vim only updates the position of its built-in labels with changes; if you need this functionality, you should use them and are limited by the number of existing labels.

There is no way; for simple user rights, you can connect to the CursorMovedI event and adapt your recorded positions, but there is no way to connect Ex commands, such as :append .

If you need a couple of labels for the plugin, itโ€™s good practice to let the user customize the labels used by the script (for example, through the variable g:MyPlugin_UseMarks ); hardly anyone uses all the tags all the time, but different people have different preferences.

+2
source

Unlimited label I donโ€™t know, but you can create a dictionary type, the key is your "label" name, value is the cursor position.

position can be obtained and set using

 getpos() and setpos() 

or do you want the actual codes?

0
source

All Articles