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?
@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
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 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.
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-> 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.
I use the package goto-chg, that let you navigate to the point of edits in the buffer, with two functions