This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-08
Channels
- # babashka (1)
- # babashka-sci-dev (42)
- # beginners (3)
- # calva (9)
- # clj-kondo (1)
- # cljs-dev (1)
- # clojure (52)
- # clojure-europe (3)
- # clojure-spec (6)
- # clojurescript (35)
- # defnpodcast (1)
- # guix (1)
- # honeysql (3)
- # hugsql (4)
- # humbleui (1)
- # introduce-yourself (3)
- # jobs (1)
- # jobs-discuss (9)
- # lsp (57)
- # off-topic (65)
- # polylith (4)
- # portal (11)
- # releases (1)
- # remote-jobs (2)
- # shadow-cljs (19)
- # tools-deps (4)
- # vim (11)
- # xtdb (8)
Does anyone know of a plugin like vim-sexp that can deal with key-value pairs in maps as single text objects? I often want to use something like >e
to swap k-v pairs in a map or change them with cie
, but of course keys and values are regarded separately.
I have wanted this for a long time as well. Recently the clojure-lsp project has enabled moving up and down these kinds of pairs. With it, you can also move let bindings up and down as well.
Very nice! I also use clojure-lsp on coc, but never really looked into actions there (I only recently began using it). Drag backward/forward
does the trick for me with k-v pairs stacked vertically, but not if they are horizontally arranged. But they can even be sorted by key with Sort map
, even with non-keyword keys, which is awesome!

The function also shows up in coc when I am inside a “horizontal map”, but it doesn’t seem to do anything compared to the “vertical map”.
You can also move a kv using just vim-sexp by selecting both the k and the v in visual mode and using https://github.com/guns/vim-sexp#list-manipulation-normal-visual=. You can even select multiple neighbouring kvs and move them this way.
I have a pseudo text object which I call a pair - it is a pair of SEXP elements. There are 2 variants forward and backward, depending which element I need to be a pair to the one under my cursor. Another insight is that SEXP's operation to move element works on any number of elements, meaning that I just need a way to select two elements, the movement of the pair is done by SEXP <Plug>(sexp_swap_element_forward)
https://github.com/nbardiuk/dotfiles/blob/fc61451baa1df5d03d2e59c1dd3b5151915b760d/nix/.config/nixpkgs/home/init.fnl#L528-L546