Skip to content

Instantly share code, notes, and snippets.

@jmervine
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmervine/9534018 to your computer and use it in GitHub Desktop.
Save jmervine/9534018 to your computer and use it in GitHub Desktop.
" :MakeTestFile
" run make test/unit on file
"
" mapping:
" nnoremap <silent> <leader>tt :MakeTest %
"
command! -nargs=+ MakeTest call s:MakeTestFile(<q-args>)
function! s:MakeTestFile(current_file)
echo a:current_file
let test_file_path = substitute(expand(a:current_file), "yp", "test/unit", "")
execute '! make '. test_file_path
1
endfunction
" :Shell <cmd>
" put shell command in new buffer.
command! -complete=shellcmd -nargs=+ Shell call s:RunShellCommand(<q-args>)
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment