I would like to tag or annotate lines so that I can later refer to those lines and perform commands on them. I wouldn't like for the tag to be in the actual text but external metadata. Is there any way for this to be possible?
As statox mentions in the comment, the simplest version is marks. You can use viminfo-related options to make sure these are persisted between vim instances.
The idea is to
m and a letter on a line (or the ex commands
:k). Lower-case is file-specific; upper-case is global.
' with the mark name to get back to the line or
` to get back to the line and column. You can also use marks in ranges at the ex command prompt.
Vim also sets some builtin marks that are symbols rather than letters. You may have seen the range
:'<,'> when pressing the colon key in visual mode—now you know why.
For more advanced cases, or for plugin authors who wish to not overwrite user marks, text properties would be a better direction (as also indicates in the comments by Christian).