Commit e1c6b0e

mo khan <mo@mokhan.ca>
2014-05-29 15:41:47
add mapping to inline temp variable.
1 parent 6e13ee4
Changed files (1)
vimrc
@@ -139,6 +139,18 @@ function! AddParameter()
 
   call setpos(".", cursor_position)
 endfunction
+
+function! InlineTemp()
+  let cursor_position = getpos(".")
+  normal "ayiw
+  normal $"byaW
+  normal dd
+  normal vip
+  exec ':%s/' . @a . '/' . @b . '/'
+  exec "normal \<Esc>"
+  call setpos(".", cursor_position)
+endfunction
+
 " }}}}
 
 "" File type-specific settings {{{{
@@ -316,6 +328,7 @@ nnoremap <leader>T :!ctags -f tags -R<cr>
 
 " ruby refactorings
 nnoremap <leader>rap :RAddParameter<cr>
+nnoremap <leader>rit :RInlineTemp<cr>
 
 " }}}}
 
@@ -329,6 +342,7 @@ cnoremap <expr> <C-P> getcmdline()[getcmdpos()-2] ==# ' ' ? expand('%:p:h') : "\
 command! KillWhitespace :normal :%s/ *$//g<cr><c-o><cr>
 
 command! RAddParameter call AddParameter()
+command! RInlineTemp call InlineTemp()
 
 " }}}