vim

For discussion on all things (neo)vim.
walterl 2020-10-09T14:56:48.037800Z

So <e and >e (from tpope/vim-sexp-mappings-for-regular-people) are super useful for moving elements around. Is there something similar for rearranging map items (key with its value) simultaneously? I.e. move elements around, two at a time

👀 1
walterl 2020-10-10T19:35:16.043Z

Hmmm... I don't seem to have such visual mode mappings by default, but this seems to do the trick 🎉:

vmap <e <Plug>(sexp_swap_element_backward)
vmap >e <Plug>(sexp_swap_element_forward)

nbardiuk 2020-10-09T15:59:59.038Z

nmap >p 3>e3B3>e
  nmap <p 2<e4E2<e
it is a hack - move each element of *p*air one at a time does not work if you try to move on the edge of the form

❤️ 1
walterl 2020-10-09T16:02:49.038500Z

that's pretty cool!

nbardiuk 2020-10-09T16:51:16.038700Z

turns out that sexp supports moving around visually selected pairs. I've created a PR for missing mapping https://github.com/tpope/vim-sexp-mappings-for-regular-people/pull/12 . If you have the mapping from the PR than swapping pairs is

nmap >p vaeE>eo<Esc>
nmap <p vaeE<eo<Esc>
selects around current element, moves to the next, visually swaps, moves cursor to the beginning of selection and exists visual mode

🦜 1
nbardiuk 2020-10-09T16:51:46.039Z

this way it works on the edges of a form

Olical 2020-10-09T21:33:49.041900Z

I use the visual selection approach too.

walterl 2020-10-09T21:44:56.042100Z

I have < and > vmaped; will test with those mappings removed 👍