I pressed me instead of 'e and the mark "e" got overwritten with the current position, instead of jumping to it. How do I undo it?


:delmarks e will delete a specific mark. It can be abbreviated :delm e

From the wiki:

Command          Description
:delmarks a      delete mark a
:delmarks a-d    delete marks a, b, c, d
:delmarks abxy   delete marks a, b, x, y
:delmarks aA     delete marks a, A
:delmarks!       delete all lowercase marks for the current buffer (a-z)

To address your comment:

In order to save a history of your marks, you need to write a viminfo file using :wv[iminfo][!] [file].

The viminfo file is used to store:
- The command line history.
- The search string history.
- The input-line history.
- Contents of non-empty registers.
- Marks for several files.
- File marks, pointing to locations in files.
- Last search/substitute pattern (for 'n' and '&').
- The buffer list.
- Global variables.

This can be read back with :rv[iminfo][!] [file].

There is a big caveat to using an viminfo file to store your marks. It will only store uppercase or numerical marks. Not lowercase marks.

Lowercase marks 'a to 'z are remembered as long as the file remains in the buffer list. If you remove the file from the buffer list, all its marks are lost. If you delete a line that contains a mark, that mark is erased.

  • No. I just want to revert the mark to its previous position and jump to it. It's like accidently using "Quick save" instead of "Quick load" and wanting to restore the overwritten save file. If it is not possible in Vim, how to prepare it in advance (i.e. make Vim save some history for each mark slot). – Vi. Dec 12 '13 at 15:30

Once you have "overwritten" a mark with a new location it cannot be undone. The best you can do is possibly press ctrl-o until your cursor is at the old location and create the mark again.

  • How to make Vim store some history [for each mark slot] to be able to undo this? I don't want to stop&think each time I save mark or jump. – Vi. Dec 12 '13 at 23:34
  • What I am trying to tell you is that Vim does not do that, and does not provide a mechanism to do it. You could possibly see if someone has tried making a Vim script/plugin that does, but I didn't see one with a cursory Google search. – Heptite Dec 13 '13 at 21:36

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.