Spacemacs already comes with the drag-stuff package, but it's bound to a transient mode (
SPC x . opens it), so if you want to have quicker access you can do this:
Go to your Spacemacs dotfile (either
.spacemacs.d/init.el; you can open it by pressing
SPC f e d)
Then inside the expression starting with:
(defun dotspacemacs/user-config ()
- Add the lines:
(global-set-key (kbd "s-J") 'drag-stuff-down) (global-set-key (kbd "s-K") 'drag-stuff-up)
To load the new settings, you can reload the entire dotfile with
SPC f e R or set the cursor ("point") inside each of the two expressions and press
, e c, which evals the expression the cursor is currently inside.
I'm on macOS and
s corresponds to the Command key. Note that the
K are capitalized, so the keybindings correspond to
Command Shift j and
Command Shift k. Feel free to change to whatever you like best.
If you're editing markdown, Spacemacs already comes with two easy keybindings to move items up and down:
That is a
markdown-mode keybinding that uses
outline and has the added advantage of moving the whole item up and down, so if you're on a multiline list item or one the has nested items inside it, it moves the entire thing without breaking formatting.