0

Is there a emacs command to tranpose the line from the point till end of the line. For example:

quick brown fox jumps over **<point>** the lazy dog meaning

After transpose it should be

the lazy dog meaning **<point>** quick brown fox jumps over
2
  • 1
    C-k C-a C-y is quick to do: I've never felt the need to have a special command for such a (fairly uncommon IME) operation.
    – NickD
    Commented Dec 4, 2019 at 19:07
  • Wow. Never thought of this way. I used to do the same with 5 key combinations C-SPC C-e C-w C-a C-y. Thanks this definitely helps. Commented Dec 4, 2019 at 19:27

1 Answer 1

1

I'm not aware of any built-in functions, but here's a quick & dirty one:

(defun my/transpose-line-around-point (p)
  "Transpose text preceding line around POINT."
  (interactive "d")
  (let ((line-beginning (save-excursion (beginning-of-line-text) (point)))
    (line-end (save-excursion (end-of-line) (point))))
    (transpose-regions line-beginning p p line-end)))

It could be tweaked to handle spaces better when whitespace comes between the point and some text preceding the end of line.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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