Vimrc:检查是否安装了unix命令

时间:2016-07-28 07:37:15

标签: vim

我在我的vimrc中有这些:

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

在markdown文件中,我想使用par进行格式化。它运行良好,但如果系统上没有安装“par”,我会收到警告。我想知道是否有办法检查并且只在安装par时设置“formatprg = par \ -78”,否则使用VIM的默认格式。

如果有任何建议,我将不胜感激。

1 个答案:

答案 0 :(得分:6)

if executable('par')
  " stuff
endif