2

when i am editing a large file, often need to view other sections of the same buffer only once. But after that I need to go back to the position I was editing at. Is there a key for doing that?

  • 2
    Possible duplicate of How to switch back and forth between two locations in a buffer – phils May 16 '18 at 0:07
  • @phils: Yep, it's a duplicate, at least as responded to by answers. But it would be good to edit the question so that it isn't limited to bouncing between two positions but instead is about moving among two or more positions. – Drew May 16 '18 at 14:23
  • the difference is that there is no need for saving a seccond position. often i only need to visit a few places where some text is found, then return to the original but only want to visit the others once. – Alvaro Martinez May 16 '18 at 19:07
  • Yes, but the generalisation of the earlier question is "how do I store arbitrary positions and return to them later", and the solutions apply just as well when there is only one such position to remember. – phils May 16 '18 at 21:06
3

@Aaron answered well with the usual way to take care of this in Emacs: set a mark where you are now, then get back to it later using C-u C-SPC.

Another way is to use a bookmark, in particular a temporary bookmark (unless you want to get back to the position in a later Emacs session).

You can easily create (and delete) temporary bookmarks using Bookmark+. You can also automatically highlight them (in various ways), so you can easily see where they are.

You can even automatically create temporary bookmarks as you move around, if you like. They can be created whenever you are idle for a given period of time. User options determine how many such automatic bookmarks to create, and where to create them (e.g. how far apart, minimally).

See also autonamed bookmarks, which can be temporary or persistent.

2

Whenever I make a large jump in a file, I press C-SPC C-SPC first. That sets the mark to the current value of point*, effectively remembering the current cursor position. Then, once I'm done wandering around, I press C-u C-SPC to jump back to that position.

If you know that you're initiating your jump with a command that sets the mark for you (most prominently, M-< or M-> for jumping to the beginning or end of the buffer, respectively), you can also skip explicitly remembering the mark. Commands that have this property will say something like "Push mark at previous position" in their help.

Finally, once you've remembered a position, you might want to toggle back to it briefly without forgetting where you are right now. The key for that is C-x C-x (optionally followed by a C-g to disable the region); that exchanges the current values of point and mark.

(*) Technically, one C-SPC is enough to set the mark; the second deactivates the region so I'm not highlighting things extraneously.

0

I use the package goto-chg, that let you navigate to the point of edits in the buffer, with two functions goto-last-change and goto-last-change-reverse.

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.