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.
- Or simply type [K](K) on any word to find its documentation!
- 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
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):
@ -32,7 +34,6 @@ or press a sequence of keys
~~~ normal
<Esc>0f<Space>d3wP$P
~~~
Text within <'s and >'s (like `<Enter>`{normal}) describes a key to press
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
!! NOTE: Before executing any of the steps below,
read this entire lesson !!
!! NOTE: Before executing any of the steps below, read this entire lesson !!
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.
NOTE: As you go through this tutor, do not try to memorize, learn by
usage.
NOTE: As you go through this tutor, do not try to memorize everything,
your Vim vocabulary will expand with usage. Consider returning to
this tutor periodically for a refresher.
# Lesson 1.4: TEXT EDITING: INSERTION
@ -170,7 +171,6 @@ There is also some text missing here.
~~~ cmd
:wq
~~~
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
@ -184,15 +184,11 @@ There is also some text missing here.
h (left) j (down) k (up) l (right)
2. To start Vim from the shell prompt type:
~~~ sh
$ nvim FILENAME
~~~
3. To exit Vim type: `<Esc>`{normal} `:q!`{vim} `<Enter>`{normal} to trash
all changes.
OR type: `<Esc>`{normal} `:wq`{vim} `<Enter>`{normal} to save
the changes.
3. To exit Vim type: `<Esc>`{normal} `:q!`{vim} `<Enter>`{normal} to trash 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}
@ -239,8 +235,7 @@ Somebody typed the end of this line twice. end of this line twice.
# Lesson 2.3: ON OPERATORS AND MOTIONS
Many commands that change text are made from an [operator](operator) and
a [motion](navigation).
Many commands that change text are made from an [operator](operator) and a [motion](navigation).
The format for a delete command with the [d](d) delete operator is as follows:
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. **
1. Move the cursor to the line below marked ✗ and place it on the
first error.
1. Move the cursor to the line below marked ✗ and place it on the first error.
2. Type `x`{normal} to delete the first unwanted character.
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.
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
commands.
7. Now type `<C-r>`{normal} (Control + R) a few times to redo the commands
(undo the undos).
6. Now type `u`{normal} a few times to undo the `U`{normal} and preceding commands.
7. Now type `<C-r>`{normal} (Control + R) a few times to redo the commands.
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}
5. The format for a change command is:
operator [number] motion
where:
operator - is what to do, such as [d](d) for delete
[number] - is an optional count to repeat the motion
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" ).
4. Press `<Esc>`{normal} and move to the next character that needs to be
changed.
4. Press `<Esc>`{normal} and move to the next character that needs to be changed.
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!!
1. Hold down the `<Ctrl>`{normal} key and press `g`{normal}. We call this
`<C-g>`{normal}. A message will appear at the bottom of the page with the
filename and the position in the file. Remember the line number for
Step 3.
1. Hold down the `<Ctrl>`{normal} key and press `g`{normal}. We call this `<C-g>`{normal}.
A message will appear at the bottom of the page with the filename and
the position in the file. Remember the line number for Step 3.
NOTE: You may see the cursor position in the lower right corner of the
screen. This happens when the ['ruler']('ruler') option is set.
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.
@ -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
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
for.
2. Now type 'errroor' `<Enter>`{normal}. This is the word you want to search for.
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).
4. To search for a phrase in the backward direction, use [?](?) instead
of `/`{normal}.
4. To search for a phrase in the backward direction, use [?](?) instead 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
further. `<C-i>`{normal} goes forward.
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 further. `<C-i>`{normal} goes forward.
"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
:s/thee/the/
~~~
NOTE that the [:s](:s) command only changed the first occurrence of "thee" in the line.
NOTE: the [:s](:s) command only changed the first match of "thee" in the line.
3. Now type
~~~ cmd
:s/thee/the/g
~~~
Adding the g [flag](:s_flags) means to substitute globally 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
:!rm TEST
~~~
# Lesson 5.3: SELECTING TEXT TO WRITE
** 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
:'<,'>
`:'<,'>`{vim}
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}.
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
the cursor around to make the selection bigger or smaller. Then you can
use an operator to do something with the text. For example, `d`{normal}
deletes the text.
NOTE: Pressing [v](v) starts [Visual selection](visual-mode). You can move the cursor around to
make the selection bigger or smaller. Then you can use an operator to
do something with the text. For example, `d`{normal} deletes the text.
# 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".
3. Type the lowercase letter `a`{normal} to [append](a) text AFTER the
cursor.
3. Type the lowercase letter `a`{normal} to [append](a) text AFTER the cursor.
4. Complete the word like the line below it. Press `<Esc>`{normal} to exit
Insert mode.
4. Complete the word like the line below it. Press `<Esc>`{normal} to exit Insert mode.
5. Use `e`{normal} to move to the next incomplete word and repeat steps 3
and 4.
5. Use `e`{normal} to move to the next incomplete word and repeat steps 3 and 4.
This li will allow you to pract appendi 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 456 gives you 579.
NOTE: Replace mode is like Insert mode, but every typed character deletes an
existing character.
NOTE: Replace mode is like Insert mode, but every typed character
deletes an existing character.
# 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
:set invic
~~~
# Lesson 7.1: GETTING HELP
** Use the on-line help system. **
Vim has a comprehensive on-line help system. To get started, try one of
these three:
Vim has a comprehensive on-line help system.
To get started, try one of these three:
- press the `<HELP>`{normal} key (if you have one)
- press the `<F1>`{normal} key (if you have one)
- type
`:help`{vim}
- type `:help`{vim}
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.
@ -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.
1. Start editing the "vimrc" file.
`:call mkdir(stdpath('config'),'p')`{vim}
`:exe 'edit' stdpath('config').'/init.vim'`{vim}
2. Write the file with:
`:w`{vim}
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}
3. Press `<C-d>`{normal} and Vim will show a list of commands that start
with "e".
3. Press `<C-d>`{normal} and Vim will show a list of commands beginning with "e".
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}
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
`:help`{vim}.
NOTE: Completion works for many commands. It is especially useful for `:help`{vim}.
# 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
them:
- *Learn Vim Progressively*: http://yannesposito.com/Scratch/en/blog/Learn-Vim-Progressively/
- *Learning Vim in 2014*: http://benmccormick.org/learning-vim-in-2014/
- *Vimcasts*: http://vimcasts.org/
- *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
- *Learn Vim Progressively*:
http://yannesposito.com/Scratch/en/blog/Learn-Vim-Progressively/
- *Learning Vim in 2013*:
http://benmccormick.org/learning-vim-in-2014/
- *Vimcasts*:
http://vimcasts.org/
- *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
(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-tutor-mode by Felipe Morales.
// vim: nowrap

View File

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