vimtutor.bat 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. :: Start Vim on a copy of the tutor file.
  2. @echo off
  3. :: Usage: vimtutor [-console] [xx]
  4. ::
  5. :: -console means gvim will not be used
  6. :: xx is a language code like "es" or "nl".
  7. :: When an xx argument is given, it tries loading that tutor.
  8. :: When this fails or no xx argument was given, it tries using 'v:lang'
  9. :: When that also fails, it uses the English version.
  10. :: Use Vim to copy the tutor, it knows the value of $VIMRUNTIME
  11. FOR %%d in (. %TMP% %TEMP%) DO (
  12. call :test_dir_writable "%~dpf0" %%d
  13. IF NOT ERRORLEVEL 1 GOTO dir_ok
  14. )
  15. echo No working directory is found
  16. GOTO end
  17. :test_dir_writable
  18. SET TUTORCOPY=%2\$tutor$
  19. COPY %1 %TUTORCOPY% >nul 2>nul
  20. GOTO end
  21. :dir_ok
  22. SET xx=%1
  23. IF NOT .%1==.-console GOTO use_gui
  24. SHIFT
  25. SET xx=%1
  26. GOTO use_vim
  27. :use_gui
  28. :: Try making a copy of tutor with gvim. If gvim cannot be found, try using
  29. :: vim instead. If vim cannot be found, alert user to check environment and
  30. :: installation.
  31. :: The script tutor.vim tells Vim which file to copy.
  32. start "dummy" /b /w "%~dp0gvim.exe" -u NONE -c "so $VIMRUNTIME/tutor/tutor.vim"
  33. IF ERRORLEVEL 1 GOTO use_vim
  34. :: Start gvim without any .vimrc, set 'nocompatible'
  35. start "dummy" /b /w "%~dp0gvim.exe" -u NONE -c "set nocp" %TUTORCOPY%
  36. GOTO end
  37. :use_vim
  38. :: The script tutor.vim tells Vim which file to copy
  39. call vim -u NONE -c "so $VIMRUNTIME/tutor/tutor.vim"
  40. IF ERRORLEVEL 1 GOTO no_executable
  41. :: Start vim without any .vimrc, set 'nocompatible'
  42. call vim -u NONE -c "set nocp" %TUTORCOPY%
  43. GOTO end
  44. :no_executable
  45. ECHO.
  46. ECHO.
  47. ECHO No vim or gvim found in current directory or PATH.
  48. ECHO Check your installation or re-run install.exe
  49. :end
  50. :: remove the copy of the tutor
  51. IF EXIST %TUTORCOPY% DEL %TUTORCOPY%
  52. SET xx=