fix(tutor): formatting, layout #15098

* fix(tutor): adjust over-80ch lines and corresponding expect file
* fix(tutor): standardise indentation and formatting, add nowrap modeline

- unifies the formatting/layout, which was a bit inconsistent,
- adds a nowrap modeline

Since the tutor uses a lot of conceals, which are included in the character
count when calculating line wrapping, lines were breaking at what looked like
odd spots, which gives a poor first impression and lowered readability.

I have adjusted some lines to be over 80ch in the source, but once they're
rendered out with conceals, they're actually under 80, so even with nowrap we
don't visually extend past 80.

fix #15088
This commit is contained in:
Oliver Marriott 2021-08-30 22:27:35 +10:00 committed by GitHub
parent 325fad8983
commit c52ec8f9eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 144 additions and 148 deletions

View File

@ -21,7 +21,9 @@ This tutorial is interactive, and there are a few things you should know.
- Type [<Enter>](<Enter>) on links [like this](holy-grail ) to open the linked help section. - Type [<Enter>](<Enter>) on links [like this](holy-grail ) to open the linked help section.
- Or simply type [K](K) on any word to find its documentation! - Or simply type [K](K) on any word to find its documentation!
- Sometimes you will be required to modify text like - Sometimes you will be required to modify text like
this here
this here
Once you have done the changes correctly, the ✗ sign at the left will change Once you have done the changes correctly, the ✗ sign at the left will change
to ✓. I imagine you can already see how neat Vim can be. ;) to ✓. I imagine you can already see how neat Vim can be. ;)
Other times, you'll be prompted to run a command (I'll explain this later): Other times, you'll be prompted to run a command (I'll explain this later):
@ -32,7 +34,6 @@ or press a sequence of keys
~~~ normal ~~~ normal
<Esc>0f<Space>d3wP$P <Esc>0f<Space>d3wP$P
~~~ ~~~
Text within <'s and >'s (like `<Enter>`{normal}) describes a key to press Text within <'s and >'s (like `<Enter>`{normal}) describes a key to press
instead of text to type. instead of text to type.
@ -63,8 +64,7 @@ NOTE: The cursor keys should also work. But using hjkl you will be able to
# Lesson 1.2: EXITING VIM # Lesson 1.2: EXITING VIM
!! NOTE: Before executing any of the steps below, !! NOTE: Before executing any of the steps below, read this entire lesson !!
read this entire lesson !!
1. Press the <Esc> key (to make sure you are in Normal mode). 1. Press the <Esc> key (to make sure you are in Normal mode).
@ -104,8 +104,9 @@ The ccow jumpedd ovverr thhe mooon.
5. Now that the line is correct, go on to Lesson 1.4. 5. Now that the line is correct, go on to Lesson 1.4.
NOTE: As you go through this tutor, do not try to memorize, learn by NOTE: As you go through this tutor, do not try to memorize everything,
usage. your Vim vocabulary will expand with usage. Consider returning to
this tutor periodically for a refresher.
# Lesson 1.4: TEXT EDITING: INSERTION # Lesson 1.4: TEXT EDITING: INSERTION
@ -170,7 +171,6 @@ There is also some text missing here.
~~~ cmd ~~~ cmd
:wq :wq
~~~ ~~~
Note you'll need to press `<Enter>` to execute the command. Note you'll need to press `<Enter>` to execute the command.
5. If you have quit vimtutor in step 1 restart the vimtutor and move down 5. If you have quit vimtutor in step 1 restart the vimtutor and move down
@ -184,15 +184,11 @@ There is also some text missing here.
h (left) j (down) k (up) l (right) h (left) j (down) k (up) l (right)
2. To start Vim from the shell prompt type: 2. To start Vim from the shell prompt type:
~~~ sh ~~~ sh
$ nvim FILENAME $ nvim FILENAME
~~~ ~~~
3. To exit Vim type: `<Esc>`{normal} `:q!`{vim} `<Enter>`{normal} to trash all changes.
3. To exit Vim type: `<Esc>`{normal} `:q!`{vim} `<Enter>`{normal} to trash OR type: `<Esc>`{normal} `:wq`{vim} `<Enter>`{normal} to save the changes.
all changes.
OR type: `<Esc>`{normal} `:wq`{vim} `<Enter>`{normal} to save
the changes.
4. To delete the character at the cursor type: `x`{normal} 4. To delete the character at the cursor type: `x`{normal}
@ -239,8 +235,7 @@ Somebody typed the end of this line twice. end of this line twice.
# Lesson 2.3: ON OPERATORS AND MOTIONS # Lesson 2.3: ON OPERATORS AND MOTIONS
Many commands that change text are made from an [operator](operator) and Many commands that change text are made from an [operator](operator) and a [motion](navigation).
a [motion](navigation).
The format for a delete command with the [d](d) delete operator is as follows: The format for a delete command with the [d](d) delete operator is as follows:
d motion d motion
@ -318,16 +313,13 @@ it would be easier to simply type two d's to delete a line.
** Press `u`{normal} to undo the last commands, `U`{normal} to fix a whole line. ** ** Press `u`{normal} to undo the last commands, `U`{normal} to fix a whole line. **
1. Move the cursor to the line below marked ✗ and place it on the 1. Move the cursor to the line below marked ✗ and place it on the first error.
first error.
2. Type `x`{normal} to delete the first unwanted character. 2. Type `x`{normal} to delete the first unwanted character.
3. Now type `u`{normal} to undo the last command executed. 3. Now type `u`{normal} to undo the last command executed.
4. This time fix all the errors on the line using the `x`{normal} command. 4. This time fix all the errors on the line using the `x`{normal} command.
5. Now type a capital `U`{normal} to return the line to its original state. 5. Now type a capital `U`{normal} to return the line to its original state.
6. Now type `u`{normal} a few times to undo the `U`{normal} and preceding 6. Now type `u`{normal} a few times to undo the `U`{normal} and preceding commands.
commands. 7. Now type `<C-r>`{normal} (Control + R) a few times to redo the commands.
7. Now type `<C-r>`{normal} (Control + R) a few times to redo the commands
(undo the undos).
Fiix the errors oon thhis line and reeplace them witth undo. Fiix the errors oon thhis line and reeplace them witth undo.
@ -341,8 +333,11 @@ Fiix the errors oon thhis line and reeplace them witth undo.
4. To repeat a motion prepend it with a number: `2w`{normal} 4. To repeat a motion prepend it with a number: `2w`{normal}
5. The format for a change command is: 5. The format for a change command is:
operator [number] motion operator [number] motion
where: where:
operator - is what to do, such as [d](d) for delete operator - is what to do, such as [d](d) for delete
[number] - is an optional count to repeat the motion [number] - is an optional count to repeat the motion
motion - moves over the text to operate on, such as: motion - moves over the text to operate on, such as:
@ -403,8 +398,7 @@ NOTE: Remember that you should be learning by doing, not memorization.
3. Type `ce`{normal} and the correct word (in this case, type "ine" ). 3. Type `ce`{normal} and the correct word (in this case, type "ine" ).
4. Press `<Esc>`{normal} and move to the next character that needs to be 4. Press `<Esc>`{normal} and move to the next character that needs to be changed.
changed.
5. Repeat steps 3 and 4 until the first sentence is the same as the second. 5. Repeat steps 3 and 4 until the first sentence is the same as the second.
@ -460,13 +454,13 @@ Now go on to the next lesson.
NOTE: Read this entire lesson before executing any of the steps!! NOTE: Read this entire lesson before executing any of the steps!!
1. Hold down the `<Ctrl>`{normal} key and press `g`{normal}. We call this 1. Hold down the `<Ctrl>`{normal} key and press `g`{normal}. We call this `<C-g>`{normal}.
`<C-g>`{normal}. A message will appear at the bottom of the page with the A message will appear at the bottom of the page with the filename and
filename and the position in the file. Remember the line number for the position in the file. Remember the line number for Step 3.
Step 3.
NOTE: You may see the cursor position in the lower right corner of the NOTE: You may see the cursor position in the lower right corner of the
screen. This happens when the ['ruler']('ruler') option is set. screen. This happens when the ['ruler']('ruler') option is set.
2. Press [G](G) to move you to the bottom of the file. 2. Press [G](G) to move you to the bottom of the file.
Type [gg](gg) to move you to the start of the file. Type [gg](gg) to move you to the start of the file.
@ -482,17 +476,16 @@ NOTE: You may see the cursor position in the lower right corner of the
1. In Normal mode type the `/`{normal} character. Notice that it and the 1. In Normal mode type the `/`{normal} character. Notice that it and the
cursor appear at the bottom of the screen as with the `:`{normal} command. cursor appear at the bottom of the screen as with the `:`{normal} command.
2. Now type 'errroor' `<Enter>`{normal}. This is the word you want to search 2. Now type 'errroor' `<Enter>`{normal}. This is the word you want to search for.
for.
3. To search for the same phrase again, simply type [n](n). 3. To search for the same phrase again, simply type [n](n).
To search for the same phrase in the opposite direction, type [N](N). To search for the same phrase in the opposite direction, type [N](N).
4. To search for a phrase in the backward direction, use [?](?) instead 4. To search for a phrase in the backward direction, use [?](?) instead of `/`{normal}.
of `/`{normal}.
5. To go back to where you came from press `<C-o>`{normal} (keep `<Ctrl>`{normal} pressed down while pressing the letter `o`{normal}). Repeat to go back 5. To go back to where you came from press `<C-o>`{normal}.
further. `<C-i>`{normal} goes forward. (keep `<Ctrl>`{normal} pressed down while pressing the letter `o`{normal}).
Repeat to go back further. `<C-i>`{normal} goes forward.
"errroor" is not the way to spell error; errroor is an error. "errroor" is not the way to spell error; errroor is an error.
@ -527,14 +520,12 @@ NOTE: This is very useful in debugging a program with unmatched parentheses!
~~~ cmd ~~~ cmd
:s/thee/the/ :s/thee/the/
~~~ ~~~
NOTE: the [:s](:s) command only changed the first match of "thee" in the line.
NOTE that the [:s](:s) command only changed the first occurrence of "thee" in the line.
3. Now type 3. Now type
~~~ cmd ~~~ cmd
:s/thee/the/g :s/thee/the/g
~~~ ~~~
Adding the g [flag](:s_flags) means to substitute globally in the line, Adding the g [flag](:s_flags) means to substitute globally in the line,
change all occurrences of "thee" in the line. change all occurrences of "thee" in the line.
@ -643,7 +634,6 @@ NOTE: If you were to exit Vim and start it again with `nvim TEST`, the file
~~~ cmd ~~~ cmd
:!rm TEST :!rm TEST
~~~ ~~~
# Lesson 5.3: SELECTING TEXT TO WRITE # Lesson 5.3: SELECTING TEXT TO WRITE
** To save part of the file, type `v`{normal} motion `:w FILENAME`{vim}. ** ** To save part of the file, type `v`{normal} motion `:w FILENAME`{vim}. **
@ -655,7 +645,7 @@ NOTE: If you were to exit Vim and start it again with `nvim TEST`, the file
3. Press the `:`{normal} character. At the bottom of the screen 3. Press the `:`{normal} character. At the bottom of the screen
:'<,'> `:'<,'>`{vim}
will appear. will appear.
@ -669,12 +659,12 @@ NOTE: If you were to exit Vim and start it again with `nvim TEST`, the file
before you press `<Enter>`{normal}. before you press `<Enter>`{normal}.
5. Vim will write the selected lines to the file TEST. Use `:!ls`{vim} to see it. Do not remove it yet! We will use it in the next lesson. 5. Vim will write the selected lines to the file TEST. Use `:!ls`{vim} to see it.
Do not remove it yet! We will use it in the next lesson.
NOTE: Pressing [v](v) starts [Visual selection](visual-mode). You can move NOTE: Pressing [v](v) starts [Visual selection](visual-mode). You can move the cursor around to
the cursor around to make the selection bigger or smaller. Then you can make the selection bigger or smaller. Then you can use an operator to
use an operator to do something with the text. For example, `d`{normal} do something with the text. For example, `d`{normal} deletes the text.
deletes the text.
# Lesson 5.4: RETRIEVING AND MERGING FILES # Lesson 5.4: RETRIEVING AND MERGING FILES
@ -747,14 +737,11 @@ Open up a line above this by typing O while the cursor is on this line.
2. Press `e`{normal} until the cursor is on the end of "li". 2. Press `e`{normal} until the cursor is on the end of "li".
3. Type the lowercase letter `a`{normal} to [append](a) text AFTER the 3. Type the lowercase letter `a`{normal} to [append](a) text AFTER the cursor.
cursor.
4. Complete the word like the line below it. Press `<Esc>`{normal} to exit 4. Complete the word like the line below it. Press `<Esc>`{normal} to exit Insert mode.
Insert mode.
5. Use `e`{normal} to move to the next incomplete word and repeat steps 3 5. Use `e`{normal} to move to the next incomplete word and repeat steps 3 and 4.
and 4.
This li will allow you to pract appendi text to a line. This li will allow you to pract appendi text to a line.
This line will allow you to practice appending text to a line. This line will allow you to practice appending text to a line.
@ -780,8 +767,8 @@ NOTE: [a](a), [i](i) and [A](A) all go to the same Insert mode, the only
Adding 123 to xxx gives you xxx. Adding 123 to xxx gives you xxx.
Adding 123 to 456 gives you 579. Adding 123 to 456 gives you 579.
NOTE: Replace mode is like Insert mode, but every typed character deletes an NOTE: Replace mode is like Insert mode, but every typed character
existing character. deletes an existing character.
# Lesson 6.4: COPY AND PASTE TEXT # Lesson 6.4: COPY AND PASTE TEXT
@ -875,17 +862,17 @@ NOTE: If you want to ignore case for just one search command, use [\c](/\c)
~~~ cmd ~~~ cmd
:set invic :set invic
~~~ ~~~
# Lesson 7.1: GETTING HELP # Lesson 7.1: GETTING HELP
** Use the on-line help system. ** ** Use the on-line help system. **
Vim has a comprehensive on-line help system. To get started, try one of Vim has a comprehensive on-line help system.
these three:
To get started, try one of these three:
- press the `<HELP>`{normal} key (if you have one) - press the `<HELP>`{normal} key (if you have one)
- press the `<F1>`{normal} key (if you have one) - press the `<F1>`{normal} key (if you have one)
- type - type `:help`{vim}
`:help`{vim}
Read the text in the help window to find out how the help works. Read the text in the help window to find out how the help works.
Type `<C-w><C-w>`{normal} to jump from one window to another. Type `<C-w><C-w>`{normal} to jump from one window to another.
@ -907,10 +894,12 @@ Vim has many more features than Vi, but most of them are disabled by
default. To start using more features you have to create a "vimrc" file. default. To start using more features you have to create a "vimrc" file.
1. Start editing the "vimrc" file. 1. Start editing the "vimrc" file.
`:call mkdir(stdpath('config'),'p')`{vim} `:call mkdir(stdpath('config'),'p')`{vim}
`:exe 'edit' stdpath('config').'/init.vim'`{vim} `:exe 'edit' stdpath('config').'/init.vim'`{vim}
2. Write the file with: 2. Write the file with:
`:w`{vim} `:w`{vim}
You can add all your preferred settings to this "vimrc" file. You can add all your preferred settings to this "vimrc" file.
@ -924,17 +913,15 @@ default. To start using more features you have to create a "vimrc" file.
2. Type the start of a command: `:e`{vim} 2. Type the start of a command: `:e`{vim}
3. Press `<C-d>`{normal} and Vim will show a list of commands that start 3. Press `<C-d>`{normal} and Vim will show a list of commands beginning with "e".
with "e".
4. Press `<Tab>`{normal} and Vim will complete the command name to ":edit". 4. Press `<Tab>`{normal} and Vim will complete the command name to ":edit".
5. Now add a space and the start of an existing file name: `:edit FIL`{vim} 5. Now add a space and the start of an existing file name: `:edit FIL`{vim}
6. Press `<Tab>`{normal}. Vim will complete the name (if it is unique). 6. Press `<Tab>`{normal}. Vim will complete the name ("FIL" -> "FILE", if it is unique).
NOTE: Completion works for many commands. It is especially useful for NOTE: Completion works for many commands. It is especially useful for `:help`{vim}.
`:help`{vim}.
# Lesson 7 SUMMARY # Lesson 7 SUMMARY
@ -961,13 +948,20 @@ many many more commands. Consult the help often.
There are many resources online to learn more about vim. Here's a bunch of There are many resources online to learn more about vim. Here's a bunch of
them: them:
- *Learn Vim Progressively*: http://yannesposito.com/Scratch/en/blog/Learn-Vim-Progressively/ - *Learn Vim Progressively*:
- *Learning Vim in 2014*: http://benmccormick.org/learning-vim-in-2014/ http://yannesposito.com/Scratch/en/blog/Learn-Vim-Progressively/
- *Vimcasts*: http://vimcasts.org/ - *Learning Vim in 2013*:
- *Vim Video-Tutorials by Derek Wyatt*: http://derekwyatt.org/vim/tutorials/ http://benmccormick.org/learning-vim-in-2014/
- *Learn Vimscript the Hard Way*: http://learnvimscriptthehardway.stevelosh.com/ - *Vimcasts*:
- *7 Habits of Effective Text Editing*: http://www.moolenaar.net/habits.html http://vimcasts.org/
- *vim-galore*: https://github.com/mhinz/vim-galore - *Vim Video-Tutorials by Derek Wyatt*:
http://derekwyatt.org/vim/tutorials/
- *Learn Vimscript the Hard Way*:
http://learnvimscriptthehardway.stevelosh.com/
- *7 Habits of Effective Text Editing*:
http://www.moolenaar.net/habits.html
- *vim-galore*:
https://github.com/mhinz/vim-galore
If you prefer a book, *Practical Vim* by Drew Neil is recommended often If you prefer a book, *Practical Vim* by Drew Neil is recommended often
(the sequel, *Modern Vim*, includes material specific to nvim). (the sequel, *Modern Vim*, includes material specific to nvim).
@ -978,3 +972,5 @@ University. E-mail: bware@mines.colorado.edu.
Modified for Vim by Bram Moolenaar. Modified for Vim by Bram Moolenaar.
Modified for vim-tutor-mode by Felipe Morales. Modified for vim-tutor-mode by Felipe Morales.
// vim: nowrap

View File

@ -1,45 +1,45 @@
{ {
"expect": { "expect": {
"24": -1, "25": -1,
"103": "The cow jumped over the moon.", "103": "The cow jumped over the moon.",
"124": "There is some text missing from this line.",
"125": "There is some text missing from this line.", "125": "There is some text missing from this line.",
"144": "There is some text missing from this line.", "126": "There is some text missing from this line.",
"145": "There is some text missing from this line.", "145": "There is some text missing from this line.",
"146": "There is also some text missing here.", "146": "There is some text missing from this line.",
"147": "There is also some text missing here.", "147": "There is also some text missing here.",
"220": "There are some words that don't belong in this sentence.", "148": "There is also some text missing here.",
"236": "Somebody typed the end of this line twice.", "216": "There are some words that don't belong in this sentence.",
"276": -1, "232": "Somebody typed the end of this line twice.",
"295": "This line of words is cleaned up.", "271": -1,
"290": "This line of words is cleaned up.",
"304": -1,
"305": -1,
"306": -1,
"307": -1,
"308": -1,
"309": -1, "309": -1,
"310": -1, "310": -1,
"311": -1, "324": "Fix the errors on this line and replace them with undo.",
"312": -1, "367": -1,
"313": -1, "368": -1,
"314": -1, "369": -1,
"315": -1, "370": -1,
"332": "Fix the errors on this line and replace them with undo.", "384": "When this line was typed in, someone pressed some wrong keys!",
"372": -1, "385": "When this line was typed in, someone pressed some wrong keys!",
"373": -1, "405": "This line has a few words that need changing using the change operator.",
"374": -1, "406": "This line has a few words that need changing using the change operator.",
"375": -1, "426": "The end of this line needs to be corrected using the `c$` command.",
"389": "When this line was typed in, someone pressed some wrong keys!", "427": "The end of this line needs to be corrected using the `c$` command.",
"390": "When this line was typed in, someone pressed some wrong keys!", "490": -1,
"411": "This line has a few words that need changing using the change operator.", "509": -1,
"412": "This line has a few words that need changing using the change operator.", "532": "Usually the best time to see the flowers is in the spring.",
"432": "The end of this line needs to be corrected using the `c$` command.", "725": -1,
"433": "The end of this line needs to be corrected using the `c$` command.", "730": -1,
"497": -1, "746": "This line will allow you to practice appending text to a line.",
"516": -1, "747": "This line will allow you to practice appending text to a line.",
"541": "Usually the best time to see the flowers is in the spring.", "767": "Adding 123 to 456 gives you 579.",
"735": -1, "768": "Adding 123 to 456 gives you 579.",
"740": -1, "794": "a) This is the first item.",
"759": "This line will allow you to practice appending text to a line.", "795": "b) This is the second item."
"760": "This line will allow you to practice appending text to a line.",
"780": "Adding 123 to 456 gives you 579.",
"781": "Adding 123 to 456 gives you 579.",
"807": "a) This is the first item.",
"808": "b) This is the second item."
} }
} }