help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Transposing words over middle words


From: ken
Subject: Re: Transposing words over middle words
Date: Sat, 18 Nov 2017 12:07:47 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0

On 11/15/2017 07:04 PM, Emanuel Berg wrote:
How can I transpose words jumping over
middle words?
(defun transpose-over-word ()
   (interactive)
   (transpose-subr 'forward-word 2)
   (backward-word 1)
   (transpose-subr 'forward-word -1)
   )
(local-set-key (kbd "M-a") #'transpose-over-word) ; try it

I prefer this method because it's straightforward and easy to understand, plus, it leaves the mark where it was.  However, in instances in which the middle word is at the end of the line, the result is unexpected:

With the point after the '3':

1 2 3 4
5 6 7 8

invoking M-a yields this:

1 2 5
4 3 6 7 8




reply via email to

[Prev in Thread] Current Thread [Next in Thread]