Skip to content

Commit

Permalink
Proof 29-31.
Browse files Browse the repository at this point in the history
  • Loading branch information
sjl committed Nov 20, 2012
1 parent a46fadc commit 4a86af8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
13 changes: 6 additions & 7 deletions chapters/29.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ Luckily Vim has a `normal!` command that does exactly this. Run this command:

This time Vim moves to the bottom of the file even though `G` has been mapped.

When writing Vim scripts you should **always** use `normal!`, **never** plain
old `normal`. You can't trust what keys your users will have mapped in their
`~/.vimrc` files.
When writing Vim scripts you should **always** use `normal!`, and **never** use
plain old `normal`. You can't trust what keys your users will have mapped in
their `~/.vimrc` files.

Special Characters
------------------
Expand All @@ -67,10 +67,9 @@ you'll see that it doesn't work. The problem is that `normal!` doesn't parse
special character sequences like `<cr>`.

In this case Vim thinks you wanted to search for the character sequence "f, o,
o, left angle bracket, c, r, right angle bracket", and thinks that you never
even pressed return to perform the search!

We'll talk about how to get around this in the next chapter.
o, left angle bracket, c, r, right angle bracket", and doesn't realize that you
even pressed return to perform the search! We'll talk about how to get around
this in the next chapter.

Exercises
---------
Expand Down
6 changes: 3 additions & 3 deletions chapters/30.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Execute Normal!
===============

Now that we've seen `execute` and `normal!` we can talk about a common Vimscript
idiom. Run the following command:
idiom in more detail. Run the following command:

:::vim
:execute "normal! gg/foo\<cr>dd"
Expand All @@ -24,8 +24,8 @@ the following command:
What does this do? Let's break it apart:

* `:execute "normal! ..."`: run the sequence of commands as if they were entered
in normal mode, ignoring all mappings, and replacing escape sequences with
their results.
in normal mode, ignoring all mappings, and replacing string escape sequences
with their results.
* `mq`: store the current location in mark "q".
* `A`: move to the end of the current line and enter insert mode after the last
character.
Expand Down
12 changes: 7 additions & 5 deletions chapters/31.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ expressions, but as usual there are some quirks.

Type the following text into a buffer:

:::python
:::text
max = 10

print "Starting"
Expand All @@ -17,11 +17,13 @@ Type the following text into a buffer:

print "Done"

This is the text we'll use to experiment with Vimscript's regex support.
This is the text we'll use to experiment with Vimscript's regex support. It
happens to be Python code, but don't worry if you don't know Python. It's just
an example.

I'm going to assume that you know the basics of regular expressions. If you
don't you should definitely stop reading this book and start reading [Learn
Regex the Hard Way][regex] by Zed Shaw. Come back when you're done with that.
don't you should stop reading this book and start reading [Learn Regex the Hard
Way][regex] by Zed Shaw. Come back when you're done with that.

[regex]: http://regex.learncodethehardway.org/

Expand Down Expand Up @@ -180,7 +182,7 @@ Exercises
Read `:help magic` carefully.

Read `:help pattern-overview` to see the kinds of things Vim regexes support.
Stop after the character classes.
Stop reading after the character classes.

Read `:help match`. Try running the `:match Error /\v.../` command a few times
by hand.
Expand Down

0 comments on commit 4a86af8

Please sign in to comment.