Skip to content

Mapping IdeaVim actions to Cursive actions

Dexter Gramfors edited this page Apr 14, 2016 · 3 revisions

In IdeaVim, it is possible to execute IDE commands by typing :action followed by the IDE action (https://github.com/JetBrains/ideavim#executing-ide-actions). Since IdeaVim can be configured using .ideavimrc, and the Cursive actions are available just like the regular IDEA actions, it is possible to map vim actions to Cursive actions.

In order to map vim actions to cursive actions, put mappings following this pattern in your .ideavimrc:

map [keys] :action [cursive-action-name]<CR>

For example:

map <Space>d :action :cursive.actions.paredit/kill<CR>

In order to see all available actions, type :actionlist :cursive in Cursive with IdeaVim activated. An example .ideavimrc with a subset of the available actions mapped is shown below:

" These shortcuts work best if you have <leader> mapped to something convenient like ',' or '<Space>'

" Load your regular .vimrc
source ~/.vimrc

" vim delete and change, with sexps!
map <leader>x :action :cursive.actions.paredit/kill-sexp<CR>
map <leader>d :action :cursive.actions.paredit/kill<CR>
map <leader>c :action :cursive.actions.paredit/kill-sexp<CR>i

" Since kill copies to system clipboard, it's nice to have easy access to clipboard paste
map <leader>p "+p

" Sexp editing mappings straight from paredit.vim
map <leader>J :action :cursive.actions.paredit/join<CR>
map <leader>O :action :cursive.actions.paredit/split<CR>
map <leader>S :action :cursive.actions.paredit/splice<CR>
map <leader>I :action :cursive.actions.paredit/raise<CR>

" Splice backwards and forwards
map <leader>k :action :cursive.actions.paredit/splice-killing-backwards<CR>
map <leader>j :action :cursive.actions.paredit/splice-killing-forwards<CR>

" Slurp and barf
map <leader>l :action :cursive.actions.paredit/barf-forwards<CR> 
map <leader>h :action :cursive.actions.paredit/slurp-forwards<CR>
map <leader>L :action :cursive.actions.paredit/slurp-backwards<CR>
map <leader>H :action :cursive.actions.paredit/barf-backwards<CR> 

" leader + wrapping symbol for wrapping
map <leader>( :action :cursive.actions.paredit/wrap-paren<CR>
map <leader>[ :action :cursive.actions.paredit/wrap-square<CR>
map <leader>{ :action :cursive.actions.paredit/wrap-curly<CR>
map <leader>" :action :cursive.actions.paredit/wrap-quotes<CR>

" Cycle collection
map <leader>C :action :cursive.actions.paredit/cycle-collection-type<CR>

" Evaluate sexp like in vim-fireplace
map cpp :action :cursive.repl.actions/run-top-sexp<CR>

" Force a single "parinference" when in paredit mode and reformat
map <leader>rp :action :cursive.actions.paredit/toggle<CR>:action :cursive.actions.paredit/toggle<CR>kj:action :cursive.actions.paredit/toggle<CR>:action ReformatCode<CR>
Clone this wiki locally