vim

For discussion on all things (neo)vim.
walterl 2021-06-23T18:45:20.093300Z

Mapping/macro of the day: Add Rich comment containing def for the element under the cursor: nmap <Leader>jd yie<Plug>(sexp_move_to_prev_top_element)O<CR><Up>(comment<CR>(def <C-r>" :<Esc>pB Given this snippet:

(defn plus1
  [x]
  (inc x))
With your cursor over x, the result of the above mapping is this:
(comment
  (def x :x))

(defn plus1
  [x]
  (inc x))
Got the idea from a recent thread in #beginners about evaluating nested forms in the REPL that contain vars defined outside of that form (like (inc x) in the example).

🙌 2
1