بیاموزید چطور تمرینهای Vim script خود را در Exercism آزمایش کنید.
این مسیر از دو ابزار برای اجرای مجموعهی test و تضمین بهترین شیوهها استفاده میکند:
$ vim exercise.vim
source کنید تا توابع سراسری آن در Vim در دسترس قرار گیرند:
:source %
:Vader exercise.vader
مسیرها ممکن است متفاوت باشند.
اگر میانبری راحت برای مراحل بالا میخواهید، این را در vimrc خود قرار دهید:
function! s:exercism_tests()
if expand('%:e') == 'vim'
let testfile = printf('%s/%s.vader', expand('%:p:h'),
\ tr(expand('%:p:h:t'), '-', '_'))
if !filereadable(testfile)
echoerr 'File does not exist: '. testfile
return
endif
source %
execute 'Vader' testfile
else
let sourcefile = printf('%s/%s.vim', expand('%:p:h'),
\ tr(expand('%:p:h:t'), '-', '_'))
if !filereadable(sourcefile)
echoerr 'File does not exist: '. sourcefile
return
endif
execute 'source' sourcefile
Vader
endif
endfunction
autocmd BufRead *.{vader,vim}
\ command! -buffer Test call s:exercism_tests()
پس از آن، هر فایل .vim یا .vader را از یک پوشهی تمرین باز کنید و دستور :Test را اجرا کنید.
$ vint .
برای اطلاعات دقیقتر دربارهی مسیر Vim script، لطفاً صفحهی راهنما را ببینید.