1

Is it possible to make vim marks (e.g. mm) point to the character to which they are originally set instead of the character's original line/column location?

For example, if I type mm on the first letter of the word "politicians" (Line 1, Column 72) in the example sentence below and then delete the word "entries" and then type `m my cursor will return to the original cursor position (Line 1, Column 72) which is now the location of the letter 'a' in the word "politicians". I understand that this is the expected behavior of vim, but I would like `m to instead return me to the 'p' of politicians, even though it's Line/Column location has changed.

Example sentence:

The 10-day block comes after anonymous changes were made to on politicians and businesses, as well as events like the Kennedy assassination.

I find my desired behavior far more useful for the way I write/edit (especially when using Vim beyond its original purpose of coding). Viemu, a plug-in which adds much of Vim's functionality to Word handles marks the way I desire. Unfortunately, Viemu is not a perfect port of Vim and I would prefer to compose all text (emails, essays etc and not just code) in Vim. Not knowing how to get Vim to treat marks in my desired way is one of the main reasons I do not use it exclusively.

Thank you in advance,

PS This is my first time posting on a stackexchange/superuser so please forgive me if I have not followed the proper format/protocol for asking a question and please correct me.

1
  • I was wondering if anyone had anything else to add. Ingo's response was knowledgeable but unfortunately does not present any solutions There very well may be none, but I was hoping that maybe someone else had an idea. – George Karandinos Aug 5 '14 at 19:40
0

While marks will be adjusted for added / removed lines, the column position won't; you are correct in that. Your desired behavior certainly has multiple benefits; I guess it just hasn't been implemented yet, probably because of the complexity involved. (And it would break compatibility with vi and previous Vim versions, something which isn't taken lightly.)

Though it is possible to hook into some editing actions with :autocmds, this isn't generally possible (e.g. stuff like :s cannot be intercepted), so emulating that behavior in Vimscript would be difficult, and I don't know about any such implementation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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