Add main English file runtime/tutor/tutor02
tutor02 at tutor02.utf-8tutor02.vimsrc/vimtutorhttps://github.com/vim/vim/pull/5729
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.![]()
I made no attempt to modify vimtutor.bat to handle the second chapter. I could have copied to vimtutor2.bat and changed it trivially to work with chapter two; but... lipstick on a pig. It'll be better if someone familiar with dos bat files modifies vimtutor.bat to handle another cmdline argument.
@sunwukonga pushed 1 commit.
—
You are receiving this because you are subscribed to this thread.
Comments are welcome.
Lesson 8.2 does not work in Windows, where date by itself will expect input. However system('date /t') works to just output the date (on Windows 10 at least)
Lesson 8.3 includes a line that presumably should not be there, after point 5:
4. As each error is fixed press <ESC> to return to Normal mode
Also: NOTE: A whole line deletion stored in a named register is NOT also stored in the numbered registers. This is incorrect.
Lesson 8.2 does not work in Windows, where
dateby itself will expect input. Howeversystem('date /t')works to just output the date (on Windows 10 at least)
Any suggestions for a system agnostic alternative, or just a NOTE: specifying the Windows specific behaviour?
- As each error is fixed press to return to Normal mode
[DELETING]
Also:
NOTE: A whole line deletion stored in a named register is NOT also stored in the numbered registers. This is incorrect.
Oops. [DELETING]
Also:
NOTE: A whole line deletion stored in a named register is NOT also stored in the numbered registers. This is incorrect.
I didn't test this, but I also didn't guess at it either, my misapprehension came from this sentence under :h quote0
Numbered register 1 contains the text deleted by the most recent delete or
change command, unless the command specified another register or the text is
less than one line (the small delete register is used then).
Lesson 8.2 does not work in Windows, where
dateby itself will expect input. Howeversystem('date /t')works to just output the date (on Windows 10 at least)Any suggestions for a system agnostic alternative, or just a
NOTE:specifying the Windows specific behaviour?
I think making a NOTE: about the Windows behaviour would make sense. In this situtation users are presumably being exposed to Vim's integration with external tools for the first time, which will almost always require OS-specific tweaks. So a simple note to point out that system() and :r !... etc. are calling outside Vim seems like a good idea to me.
[Question] Should I change the lesson numbering from 8.1 to 2.1.1 i.e. chapter.lesson.part. It would no longer be consistent with the original vimtutor numbering, but it would allow for much more flexibility in the future if the are multiple mutable chapters going forward.
@sunwukonga pushed 1 commit.
—
You are receiving this because you are subscribed to this thread.
Merging #5729 into master will increase coverage by
0.05%.
The diff coverage isn/a.
@@ Coverage Diff @@ ## master #5729 +/- ## ========================================== + Coverage 84.06% 84.11% +0.05% ========================================== Files 138 138 Lines 152376 152435 +59 ========================================== + Hits 128088 128225 +137 + Misses 24288 24210 -78
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/if_xcmdsrv.c | 85.99% <0%> (-0.36%) |
⬇️ |
| src/gui_gtk_x11.c | 58.06% <0%> (-0.25%) |
⬇️ |
| src/window.c | 88.66% <0%> (-0.07%) |
⬇️ |
| src/term.c | 81.34% <0%> (-0.06%) |
⬇️ |
| src/ops.c | 89.65% <0%> (-0.05%) |
⬇️ |
| src/getchar.c | 84.42% <0%> (-0.03%) |
⬇️ |
| src/if_python3.c | 83.82% <0%> (ø) |
⬆️ |
| src/version.c | 92.1% <0%> (ø) |
⬆️ |
| src/terminal.c | 82.61% <0%> (+0.03%) |
⬆️ |
| src/gui.c | 63.63% <0%> (+0.05%) |
⬆️ |
| ... and 3 more |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered by Codecov. Last update 5381c7a...3c47900. Read the comment docs.
A higher level comment: Would it be possible to make multiple of these tutor parts, and have a menu to select which one to take?
Yes, the main tutor02 file could be spliced into sections along the lines of lesson parts with a generic part (linux) and then any number of variations (Windows, Plan9, etc), I imagine most sections would only need the generic section as they wouldn't touch anything system related. E.g. [tutor02-1, tutor_win02-1, tutor_osx2-1, etc]. The tutor02.vim script could select the appropriate sections based on the environment, concatenate, and copy to the temp file. It's not my place to be opinionated on this, but overall I feel it might a bridge too far UNLESS there is a serious intent to introduce content that is heavy on system calls.
We could also have one for specific subjects, e.g. how to record and play back a macro.
I already have lessons planned for macros, is there a system environment dependency I'm ignorant of?
The user would first do the main tutor, and then gets a menu to select one of the advanced subjects. Keep in mind that the tutor is interactive and is intended to "get things in your fingers". Thus a section on writing Vim script is not a good idea.
I agree.
I guess we are not going to have several parts. Even the second chapter may not grow much.
Therefore, to keep things simple, I propose to add the sections to the existing vimtutor, and use a kind of separator in between the parts. It would say something like "now you know the basics, you can quit and start using Vim, or you can continue and learn about some more advanced features".
We can even add a list of subjects, telling the user to use a search command to jump there. Hmm, this might be difficult to find, and we don't want to put at it the top. We could put the index at the bottom, so "G" takes the user there.
About the man page: the list of options at the top is hard to read. Why not just add [options] and mention them in a table further down.
How about embedding vimtutor within vim and introducing :tutor command? This command could be mentioned on welcome screen of vim (e.g. Type :tutor to see Vim tutorial)
Moving the tutor-specific stuff into Vim would avoid the shell script and batch file - that helps.
The extra code won't be much. So that looks like a good direction to go in.
It would still be good to start the tutor from the command line. how about "vim --tutor" ?
Moving the tutor-specific stuff into Vim would avoid the shell script and batch file - that helps.
The extra code won't be much. So that looks like a good direction to go in.
It would still be good to start the tutor from the command line. how about "vim --tutor" ?
I am including this. It's a bit sad, that the new vimtutor shell script is no longer portable, but requires bash (so I changed that). I also made a few further enhancements so that we do not need a separate tutor02.vim file and made vimtutor.bat on Windows aware of a seperate chapter.
I hope I didn't brake anything. Please check it.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.![]()
—
Reply to this email directly, view it on GitHub.
You are receiving this because you commented.![]()
Would you like a POSIX shell port of vimtutor?
diff --git a/src/vimtutor b/src/vimtutor index 3faf100b4..6e29a7602 100755 --- a/src/vimtutor +++ b/src/vimtutor @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Start Vim on a copy of the tutor file. @@ -11,8 +11,7 @@ # Vim could be called "vim" or "vi". Also check for "vimN", for people who # have Vim installed with its version number. -# We anticipate up to a future Vim 8.1 version :-). -seq="vim vim81 vim80 vim8 vim74 vim73 vim72 vim71 vim70 vim7 vim6 vi" +seq="vim vim91 vim90 vim81 vim80 vim8 vim74 vim73 vim72 vim71 vim70 vim7 vim6 vi" usage() { @@ -31,94 +30,104 @@ usage() listOptions() { - declare -A language - language[bar]=Bavarian - language[bg]=Bulgarian - language[ca]=Catalan - language[cs]=Czech - language[da]=Danish - language[de]=German - language[el]=Greek - language[en]=English\(default\) - language[eo]=Esperanto - language[es]=Spanish - language[fr]=French - language[hr]=Croatian - language[hu]=Hungarian - language[it]=Italian - language[ja]=Japanese - language[ko]=Korean - language[lv]=Latvian - language[nb]=Bokmål - language[nl]=Dutch - language[no]=Norwegian - language[pl]=Polish - language[pt]=Portuguese - language[ru]=Russian - language[sk]=Slovak - language[sr]=Serbian - language[sv]=Swedish - language[tr]=Turkish - language[uk]=English - language[vi]=Vietnamese - language[zh]=Chinese - - echo "==OPTIONS=======================================================================================" - echo "Chapter: 1" - for code in bar bg ca cs da de el en eo es fr hr hu it ja ko lv nb nl no pl pt ru sk sr sv tr uk vi zh - do - printf "\tLang: %s => %s\n" ${code} ${language[${code}]} - done - echo "Chapter: 2" - for code in en - do - printf "\tLang: %s => %s\n" ${code} ${language[${code}]} - done - echo "================================================================================================" + echo "==OPTIONS=======================================================================================" + echo "Chapter: 1" + printf "\tLang: %-3s => %s\n" \ +bar Bavarian \ +bg Bulgarian \ +ca Catalan \ +cs Czech \ +da Danish \ +de German \ +el Greek \ +en English\(default\) \ +eo Esperanto \ +es Spanish \ +fr French \ +hr Croatian \ +hu Hungarian \ +it Italian \ +ja Japanese \ +ko Korean \ +lv Latvian \ +nb Bokmål \ +nl Dutch \ +no Norwegian \ +pl Polish \ +pt Portuguese \ +ru Russian \ +sk Slovak \ +sr Serbian \ +sv Swedish \ +tr Turkish \ +uk English \ +vi Vietnamese \ +zh Chinese + + echo "Chapter: 2" + printf "\tLang: %-3s => %s\n" \ +en English\(default\) + echo "================================================================================================" } validateLang() { - if [[ $xx =~ ^[^a-z]*$ ]]; then echo "Error: iso639 code must contain only [a-z]" && exit 1; fi - if [ ${#xx} == 2 ] || [ ${#xx} == 3 ]; then :; else echo "Error: iso639 code must be 2 or 3 characters only" && exit 1; fi + case "$xx" in + '' | *[!a-z]* ) + echo "Error: iso639 code must contain only [a-z]" + exit 1 + esac + + case "${#xx}" in + [23] ) + ;; + * ) + echo "Error: iso639 code must be 2 or 3 characters only" + exit 1 + esac + export xx } validateChapter() { - if [[ $cc =~ ^[0-9]*$ ]]; then :; else echo "Error: chapter argument must contain digits only" && exit 1; fi - if [ $cc == "0" ]; then echo "Error: chapter must be non-zero" && exit 1; fi - if [ $cc == "00" ]; then echo "Error: chapter must be non-zero" && exit 1; fi + case "$cc" in + '' | *[!0-9]* ) + echo "Error: chapter argument must contain digits only" + exit 1 + ;; + 0 | 00 ) + echo "Error: chapter must be non-zero" + exit 1 + esac + export CHAPTER="$cc" } -shopt -s extglob while [ "$1" != "" ]; do - case $1 in + case "$1" in -g | --gui ) seq="gvim gvim91 gvim90 gvim81 gvim80 gvim8 gvim74 gvim73 gvim72 gvim71 gvim70 gvim7 gvim6 $seq" ;; -l | --language ) shift - xx=$1 + xx="$1" validateLang ;; - -l[a-z][a-z]?([a-z]) ) xx=${1#*l} - validateLang + -l[a-z][a-z][a-z] | -l[a-z][a-z] ) + export xx="${1#*l}" ;; - --language[a-z][a-z]?([a-z]) ) xx=${1#*e} - validateLang + --language[a-z][a-z][a-z] | --language[a-z][a-z] ) + export xx="${1#*e}" ;; - [a-z][a-z]?([a-z]) ) xx=$1 - validateLang + [a-z][a-z][a-z] | [a-z][a-z] ) export xx="$1" ;; -c | --chapter ) shift - cc=$1 + cc="$1" validateChapter ;; - -c[0-9]?([0-9]) ) cc=${1#*c} - validateChapter + -c[1-9][0-9] | -c[1-9] ) export CHAPTER="${1#*c}" ;; - --chapter[0-9]?([0-9]) ) cc=${1#*r} - validateChapter + --chapter[1-9][0-9] | --chapter[1-9] ) + export CHAPTER="${1#*r}" ;; -h | --help ) usage exit @@ -129,8 +138,8 @@ while [ "$1" != "" ]; do "" ) ;; * ) usage exit 1 - esac - shift + esac + shift done @@ -161,10 +170,10 @@ fi export TUTORCOPY # remove the copy of the tutor on exit -trap "rm -rf $TODELETE" 0 1 2 3 9 11 13 15 +trap "rm -rf $TODELETE" EXIT HUP INT QUIT SEGV PIPE TERM for i in $seq; do - testvim=$(which $i 2>/dev/null) + testvim=$(command -v "$i" 2>/dev/null) if test -f "$testvim"; then VIM=$i break
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.![]()
@zzzyxwvut nice, thanks for this. I'll check it later today
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.![]()
shellcheck will also warn for non-POSIX-portable constructs if the shebang line starts uses sh
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.![]()
There will likely be other suggestions, let me draft a PR
then.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.![]()
The patch is in the master branch. #15992 is a follow-up
PR draft.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you commented.![]()