2016-07-28 43 views
1

我有這些在我的vimrc:.vimrc中:檢查UNIX命令安裝

if has("autocmd") 
augroup Misc 
    " Jump to the last known position when reopening a file 
    autocmd BufReadPost * 
     \ if line("'\"") > 1 && line("'\"") <= line("$") | 
     \ exe "normal! g`\"" | 
     \ endif 
augroup END 

augroup FTOptions 
    autocmd! 
    autocmd FileType cpp,java setlocal commentstring=//\ %s 
    autocmd FileType markdown setlocal textwidth=78 formatprg=par\ -w78 
augroup END 

在降價文件,我想這樣做使用par格式。它運行良好,但如果系統上未安裝「par」,我會收到警告。我想知道是否有一種方法可以檢查並僅在安裝par時設置「formatprg = par \ -78」,否則使用VIM的默認格式。

我將不勝感激任何建議。

回答

6
if executable('par') 
    " stuff 
endif