Skip to content

Instantly share code, notes, and snippets.

@tommcdo
Created April 30, 2014 15:15
Show Gist options
  • Save tommcdo/11429845 to your computer and use it in GitHub Desktop.
Save tommcdo/11429845 to your computer and use it in GitHub Desktop.
function! s:express(type)
let expression = input('=', '', 'expression')
let a_reg = @a
let selection = &selection
set selection=inclusive
let selectcmd = "`[v`]"
if a:type == 'line'
let selectcmd = "'[V']"
endif
execute 'normal!'.selectcmd.'"ay'
let @a = map([@a], expression)[0]
execute 'normal! '.selectcmd.'"ap'
silent! call repeat#set("\<Plug>(ExpressRepeat)".expression."\<CR>")
let &selection = selection
let @a = a_reg
endfunction
nnoremap <silent> <Plug>(ExpressRepeat) .
nnoremap <silent> <Plug>(Express) :<C-U>set operatorfunc=<SID>express<CR>g@
nmap c= <Plug>(Express)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment