7

I've recently been editing some source code where I often want to swap elements in an array that spans multiple lines.

Doing this manually is quite tedious, moving the cursor between both locations and copy-pasting twice.

It's possible to write a utility that does this - which would be much faster than copy-pasting between two locations (either with a single mouse drag, or marking two locations with the cursor).

However for all I know this may already exist.

Does Emacs provide a convenient way to do this, or is there a package this supports this feature?

Drew
  • 75,699
  • 9
  • 109
  • 225
ideasman42
  • 8,375
  • 1
  • 28
  • 105

1 Answers1

11

Function transpose-words can do that.

  • Set a mark at one word (C-SPC).
  • Move the cursor to the other word.
  • C-0 M-t

Enjoy!

Marco Wahl
  • 2,796
  • 11
  • 13