blob: 6695ee397f5b85f06385d5fceac35d73a6671beb [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001:: Start Vim on a copy of the tutor file.
2@echo off
3
Paul Desmond Parker17c71da2024-11-03 20:47:53 +01004:: Usage: vimtutor [-chapter 2] [-console] [xx]
Bram Moolenaar071d4272004-06-13 20:20:40 +00005::
6:: -console means gvim will not be used
7:: xx is a language code like "es" or "nl".
8:: When an xx argument is given, it tries loading that tutor.
9:: When this fails or no xx argument was given, it tries using 'v:lang'
10:: When that also fails, it uses the English version.
11
12:: Use Vim to copy the tutor, it knows the value of $VIMRUNTIME
Bram Moolenaar37f471d2020-03-19 17:13:40 +010013FOR %%d in (. %TMP% %TEMP%) DO (
Christian Brabandtee2cbcd2021-09-15 12:53:40 +020014 call :test_dir_writable "%~dpf0" %%d
Bram Moolenaar37f471d2020-03-19 17:13:40 +010015 IF NOT ERRORLEVEL 1 GOTO dir_ok
16)
17
18echo No working directory is found
19GOTO end
20
21:test_dir_writable
22SET TUTORCOPY=%2\$tutor$
23COPY %1 %TUTORCOPY% >nul 2>nul
24GOTO end
25
26:dir_ok
Bram Moolenaar071d4272004-06-13 20:20:40 +000027
Paul Desmond Parker17c71da2024-11-03 20:47:53 +010028IF .%1==.-chapter (
29 SET CHAPTER=%2
30 SHIFT
31 SHIFT
32)
Bram Moolenaar071d4272004-06-13 20:20:40 +000033SET xx=%1
34
35IF NOT .%1==.-console GOTO use_gui
36SHIFT
37SET xx=%1
38GOTO use_vim
39:use_gui
40
41:: Try making a copy of tutor with gvim. If gvim cannot be found, try using
42:: vim instead. If vim cannot be found, alert user to check environment and
43:: installation.
44
45:: The script tutor.vim tells Vim which file to copy.
Bram Moolenaar37f471d2020-03-19 17:13:40 +010046start "dummy" /b /w "%~dp0gvim.exe" -u NONE -c "so $VIMRUNTIME/tutor/tutor.vim"
Bram Moolenaar071d4272004-06-13 20:20:40 +000047IF ERRORLEVEL 1 GOTO use_vim
48
49:: Start gvim without any .vimrc, set 'nocompatible'
Bram Moolenaar37f471d2020-03-19 17:13:40 +010050start "dummy" /b /w "%~dp0gvim.exe" -u NONE -c "set nocp" %TUTORCOPY%
Bram Moolenaar071d4272004-06-13 20:20:40 +000051
52GOTO end
53
54:use_vim
55:: The script tutor.vim tells Vim which file to copy
Bram Moolenaardde403c2017-09-17 21:43:00 +020056call vim -u NONE -c "so $VIMRUNTIME/tutor/tutor.vim"
Bram Moolenaar071d4272004-06-13 20:20:40 +000057IF ERRORLEVEL 1 GOTO no_executable
58
59:: Start vim without any .vimrc, set 'nocompatible'
Bram Moolenaardde403c2017-09-17 21:43:00 +020060call vim -u NONE -c "set nocp" %TUTORCOPY%
Bram Moolenaar071d4272004-06-13 20:20:40 +000061
62GOTO end
63
64:no_executable
65ECHO.
66ECHO.
67ECHO No vim or gvim found in current directory or PATH.
68ECHO Check your installation or re-run install.exe
69
70:end
71:: remove the copy of the tutor
72IF EXIST %TUTORCOPY% DEL %TUTORCOPY%
73SET xx=