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
  • 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 Dec 4 '19 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. – Talespin_Kit Dec 4 '19 at 19:27
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.

| improve this answer | |

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.