[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Transposing words over middle words
From: |
Loris Bennett |
Subject: |
Re: Transposing words over middle words |
Date: |
Thu, 16 Nov 2017 08:04:39 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) |
Hi Bob,
Bob Proulx <bob@proulx.com> writes:
> TL;DR: How can I transpose words jumping over middle words?
>
> Of course we all know about C-t transpose-chars. And there is the
> corresponding M-t transpose-words too. Here is the documentation.
>
> ‘M-t’ transposes the word before point with the word after point
> (‘transpose-words’). It moves point forward over a word, dragging the
> word preceding or containing point forward as well. The punctuation
> characters between the words do not move. For example, ‘FOO, BAR’
> transposes into ‘BAR, FOO’ rather than ‘BAR FOO,’.
>
> When modifying a list of comma separated s strings this works great.
> But often I find myself wanting to transpose words in an "and"
> structure.
>
> Jack and Jill went up the hill.
>
> With the point on the space after Jack the easiest way I know to
> transpose those words is to M-d to kill-word forward deleting the
> "and" leaving.
>
> Jack and Jill went up the hill.
> ^ point is here: M-d
> Jack Jill went up the hill.
>
> Then M-t to transpose those words:
>
> Jack Jill went up the hill.
> ^ point is here: M-t
> Jill Jack went up the hill.
>
> Then restore the "and" which is somewhat inelegant
>
> Jill Jack went up the hill.
> ^ point is here: C-b C-y
> Jill and Jack went up the hill.
>
> Obviously I can use other brute force make the change.
>
> Jack and Jill went up the hill.
> ^ point is here: M-d
> Jack and went up the hill.
> ^ point is here: M-b M-b
> Jack and went up the hill.
> ^ point is here: C-y M-d M-f
> Jill and went up the hill.
> ^ point is here: C-f C-y
> Jill and Jack went up the hill.
>
> That or something similar is usually what I do. This is one of those
> nuisance items I have always wished had a better way to accomplish but
> just always worked through it by brute force. But transpose-words has
> always been taunting me that it almost does what I want with M-t but
> doesn't work in this situation.
>
> Is there a way to use M-t to transpose words skipping over middle
> words like it does for punctuation? Perhaps there isn't a better way.
Assuming I'm at the end of the three words where the transposition
should take place, I usually do
Jack and Jill went up the hill.
^ point is here: M-b
Jack and Jill went up the hill.
^ point is here: M-t
Jack Jill and went up the hill.
^ point is here: M-b M-b
Jack Jill and went up the hill.
^ point is here: M-t M-t
Jill and Jack went up the hill.
It seems moderately elegant to me, because it involves a fairly simple
ordering of only two different functions. Having said that, I don't do
it that regularly and so still often screw it up.
Cheers,
Loris
--
This signature is currently under construction.
- RE: Transposing words over middle words, (continued)
Re: Transposing words over middle words, Bob Proulx, 2017/11/16
Message not available
- Re: Transposing words over middle words, Michael Piotrowski, 2017/11/16
- Re: Transposing words over middle words, Bob Proulx, 2017/11/16
- Re: Transposing words over middle words, Eric Abrahamsen, 2017/11/16
- Re: Transposing words over middle words, Eric Abrahamsen, 2017/11/16
- put it in MELPA (was: Re: Transposing words over middle words), Emanuel Berg, 2017/11/16
- Re: put it in MELPA, Eric Abrahamsen, 2017/11/16
- Re: put it in MELPA (was: Re: Transposing words over middle words), Tim Visher, 2017/11/17
Re: Transposing words over middle words,
Loris Bennett <=
- Re: Transposing words over middle words, Joost Kremers, 2017/11/16
- Re: Transposing words over middle words, Eli Zaretskii, 2017/11/16
- Re: Transposing words over middle words, Gian Uberto Lauri, 2017/11/17
- Re: Transposing words over middle words, Gian Uberto Lauri, 2017/11/17
- Re: Transposing words over middle words, Eli Zaretskii, 2017/11/17
- Re: Transposing words over middle words, Gian Uberto Lauri, 2017/11/17