From 9ef332e065ffb75f4046f595948e13565f4724be Mon Sep 17 00:00:00 2001 From: Adam Pearson Date: Mon, 16 Apr 2012 17:49:55 -0700 Subject: [PATCH] add vim shell-out function --- vimrc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/vimrc b/vimrc index 6a866e45c1..60a3b0024e 100755 --- a/vimrc +++ b/vimrc @@ -44,3 +44,23 @@ set guifont=Inconsolata-g:h14 " CTRLP customization let g:ctrlp_working_path_mode = 0 + +command! -complete=shellcmd -nargs=+ Shell call s:RunShellCommand() +function! s:RunShellCommand(cmdline) + echo a:cmdline + let expanded_cmdline = a:cmdline + for part in split(a:cmdline, ' ') + if part[0] =~ '\v[%#<]' + let expanded_part = fnameescape(expand(part)) + let expanded_cmdline = substitute(expanded_cmdline, part, expanded_part, '') + endif + endfor + botright new + setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap + call setline(1, 'You entered: ' . a:cmdline) + call setline(2, 'Expanded Form: ' .expanded_cmdline) + call setline(3,substitute(getline(2),'.','=','g')) + execute '$read !'. expanded_cmdline + setlocal nomodifiable + 1 +endfunction