tpope / vim-fireplace

fireplace.vim: Clojure REPL support
https://www.vim.org/scripts/script.php?script_id=4978
1.75k stars 139 forks source link

Pasting result of cpp into buffer #282

Open nenadalm opened 7 years ago

nenadalm commented 7 years ago

Hi. What I thought about doing is to write some function (e.g. "do-something"), do some implementation, write test:

(deftest do-something-test
  (is (= (do-something arg1 arg2)

evaluate call using cpp and if the result is ok, then paste it into the test so after paste it would look like:

(deftest do-something-test
  (is (= (do-something arg1 arg2)
         result

I am not very expirienced with vim, but I come up with this so far:

:nmap <leader>w :redir @b <bar> :exec "norm cpp" <bar> :redir END <bar> :exec 'let @b = substitute(@b, ".*No matching autocommands\n", "", "g")'<cr>
:nmap <leader>e :put b<cr>

so now I can evaluate form with \w and paste the result with \e. Is there a way to overwrite cpp so it would paste the result into some registry or something?

maybe this could even be in the plugin? (or doc as tip?)

styts commented 7 years ago

Not sure if this helps, but there is already c!! which replaces a form with it's evaluated result.

nenadalm commented 7 years ago

@styts thanks, but I would like to copy that result and paste it (without replacing).

jeaye commented 7 years ago

This is something I'd love to have as well.

tpope commented 5 years ago

Is copying the result out of the :Last buffer good enough?