Zoltan King
Zoltan King

Reputation: 2292

Vimrc: check if unix command is installed

I have these in my 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

In markdown files I'd like to do the formatting using par. It works well, but I get a warning if "par" is not installed on the system. I'm wondering if there's a way to check and only set "formatprg=par\ -78" when par is installed, otherwise use VIM's default formatting.

I would be grateful for any suggestion.

Upvotes: 1

Views: 113

Answers (1)

Amadan
Amadan

Reputation: 198526

if executable('par')
  " stuff
endif

Upvotes: 6

Related Questions