3 # Start Vim on a copy of the tutor file.
5 # Usage: vimtutor [-g] [xx]
6 # Where optional argument -g starts vimtutor in gvim (GUI) instead of vim.
7 # and xx is a language code like "es" or "nl".
8 # When an argument is given, it tries loading that tutor.
9 # When this fails or no argument was given, it tries using 'v:lang'
10 # When that also fails, it uses the English version.
12 # Vim could be called "vim" or "vi". Also check for "vimN", for people who
13 # have Vim installed with its version number.
14 # We anticipate up to a future Vim 8 version :-).
15 seq="vim vim8 vim75 vim74 vim73 vim72 vim71 vim70 vim7 vim6 vi"
16 if test "$1" = "-g"; then
17 # Try to use the GUI version of Vim if possible, it will fall back
18 # on Vim if Gvim is not installed.
19 seq="gvim gvim8 gvim75 gvim74 gvim73 gvim72 gvim71 gvim70 gvim7 gvim6 $seq"
26 # We need a temp file for the copy. First try using a standard command.
28 TUTORCOPY
=`mktemp $tmp/tutorXXXXXX || tempfile -p tutor || echo none`
30 # If the standard commands failed then create a directory to put the copy in.
31 # That is a secure way to make a temp file.
32 if test "$TUTORCOPY" = none
; then
33 tmpdir
=$tmp/vimtutor$$
37 mkdir
$tmpdir || getout
=yes
39 if test $getout = yes; then
40 echo "Could not create directory for tutor copy, exiting."
43 TUTORCOPY
=$tmpdir/tutorcopy
52 # remove the copy of the tutor on exit
53 trap "rm -rf $TODELETE" 0 1 2 3 9 11 13 15
56 testvim
=`which $i 2>/dev/null`
57 if test -f "$testvim"; then
63 # When no Vim version was found fall back to "vim", you'll get an error message
65 if test -z "$VIM"; then
69 # Use Vim to copy the tutor, it knows the value of $VIMRUNTIME
70 # The script tutor.vim tells Vim which file to copy
71 $VIM -f -u NONE
-c 'so $VIMRUNTIME/tutor/tutor.vim'
73 # Start vim without any .vimrc, set 'nocompatible'
74 $VIM -f -u NONE
-c "set nocp" $TUTORCOPY