- 论坛徽章:
- 0
|
本帖最后由 blackfur 于 2013-10-23 22:36 编辑
“run-arg.vim- "vim global plugin for run with argments
- "define global sign
- if exists("g:loaded_runarg")
- finish
- endif
- let g:loaded_runarg= 1
- "backup original settings
- let s:save_cpo = &cpo
- set cpo&vim
- "map and menu
- if !hasmapto('<Plug>RunargRa')
- map <unique> <Leader>ra <Plug>RunargRa
- endif
- noremap <unique> <script> <Plug>RunargRa <SID>Ra
- noremenu <script> Plugin.Run\ With\ Arguments <SID>Ra
- noremap <SID>Ra :call <SID>Ra(expand("%:p:h"),expand("%:t:r"),expand("%:e"))<CR>
- "define func
- function s:Ra(filePath,fileName,fileExtension)
- let arg=input("Run ".a:fileName." with arguments: ")
- exe "w"
- if a:fileExtension=="c"
- let compiler="gcc"
- elseif a:fileExtension=="cpp"
- let compiler="g++"
- endif
- exe "!".compiler." -o ".a:filePath."\\".a:fileName.".out ".a:filePath."\\".a:fileName.".".a:fileExtension."&&".a:filePath."\\".a:fileName.".out ".arg
- echo "!".a:filePath."\\".a:fileName.".out ".arg
- endfunction
- "define a command
- if !exists(":Rwa")
- command -nargs=0 Rwa :call s:Ra(expand("%:p:h"),expand("%:t:r"),expand("%:e"))
- endif
- "restore setting
- let &cpo = s:save_cpo
复制代码 |
|