Created
May 7, 2012 20:45
-
-
Save sskirby/2630285 to your computer and use it in GitHub Desktop.
Useful vim functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vnoremap <leader>re :call ExtractVariable()<cr> | |
function! ExtractVariable() | |
let name = input("Variable name: ") | |
if name == '' | |
return | |
endif | |
normal! gv | |
exec "normal c" . name | |
exec "normal! O" . name . " = " | |
normal! $p | |
endfunction | |
nnoremap <leader>ri :call InlineVariable()<cr> | |
function! InlineVariable() | |
normal "ayiw | |
normal 4diw | |
normal "bd$ | |
normal dd | |
normal k$ | |
exec '/\<' . @a . '\>' | |
exec ':.s/\<' . @a . '\>/' . @b | |
endfunction | |
command! ShowRoutes call ShowRoutes() | |
function! ShowRoutes() | |
topleft 100 :split __Routes__ | |
set buftype=nofile | |
normal 1GdG | |
0r! rake -s routes | |
exec ":normal " . line("$") . "_ " | |
normal 1GG | |
normal dd | |
endfunction | |
nnoremap <Leader>% :<C-u>call <SID>copy_path()<CR> | |
function! s:copy_path() | |
let @*=expand('%') | |
let @"=expand('%') | |
let @+=expand('%') | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment