0

I have adviced to use C-u C-x C-x to jump back to latest position I jumped before. For example, if I do M-< and C-u C-x C-x, first I jump beginning of the file and come back to point I jumped.

When I do C-x C-x it does the same operation and also marks it. Since I don't need to mark it, is it possible to obtain C-u C-x C-xs behavior, when I press C-x C-x?

2

Better advice would have been to use C-u C-SPC to return to where the mark has been set. Using C-u C-x C-x to return to where the mark has been set runs the function exchange-point-and-mark which puts the mark where point used to be which is probably not what you wanted.

If you still want what you asked for here it is:

(defun alt-exchange-point-and-mark (&optional arg)
  (interactive "P")
  (exchange-point-and-mark (not arg)))

(global-set-key (kbd "C-x C-x") 'alt-exchange-point-and-mark)
  • When alt-exchange-point-and-mark is perform, when we jump to line, can the jumped line be on the center of the frame? @Aidan Schofield – alper Jul 17 '20 at 11:14
  • 1
    C-l will put the line that the point is in at the centre of the window. It runs the command recenter-top-bottom so you could throw that into the definition of alt-exchange-point-and-mark at the end if you wish. – Aidan Schofield Jul 17 '20 at 13:14
  • Sorry for late comment, right after M-< if I make paste, it won't get back to point I jumped instead it jumps back to starting location of where paste happens – alper Dec 10 '20 at 19:42

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.