3

More broadly, should work by the selected semantic unit (incl. paragraphs in text mode, and the relevant units in other modes). I.e., if a sentence is selected, then the notional "move-left" would move the selected sentence to before the preceding sentence; if a word is selected, then analogously, move the selected word to before the preceding word.

The solution is intended to be used in combination with expand-region https://github.com/magnars/expand-region.el

smart-shift is somewhat similar, but moves the selection by a character at a time.

transpose-words and transpose-sentences are also similar but require a negative argument to move "to the left"; and they are distinct functions, while I would like to have a single function that understands its context, i.e. whether a word, a sentence, etc. is selected.

1

Maybe drag-stuff.el is what you're looking for.

Drag Stuff is a minor mode for Emacs that makes it possible to drag stuff (words, region, lines) around in Emacs. See https://github.com/rejeep/drag-stuff.el

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.