# How to set keybindings to move lines up/down on Spacemacs

Spacemacs already comes with the  [drag-stuff](https://github.com/rejeep/drag-stuff.el)  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` or `.spacemacs.d/init.el`; you can open it by pressing `SPC f e d`)

- Then inside the expression starting with:

```lisp
(defun dotspacemacs/user-config ()
```

- Add the lines:

```lisp
(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 `J` and `K` are capitalized, so the keybindings correspond to `Command Shift j` and `Command Shift k`. Feel free to change to whatever you like best.

## Markdown

If you're editing markdown, Spacemacs already comes with two easy keybindings to move items up and down: `M-k` and `M-j`, respectively.

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.

Source: https://github.com/syl20bnr/spacemacs/pull/14449
