# HG changeset patch # User Steve Losh # Date 1487249398 0 # Node ID 469bfd3284dddc1bbb7ae1e6a2dcc9507543aaa6 # Parent 3bfec08cd774271897841d85374d43f265cd4784# Parent 2600b031f163440d47b41c56be4040d503cdd3eb Merge. diff -r 2600b031f163 -r 469bfd3284dd acknowledgements.markdown --- a/acknowledgements.markdown Sun Feb 02 21:42:29 2014 -0800 +++ b/acknowledgements.markdown Thu Feb 16 12:49:58 2017 +0000 @@ -16,29 +16,41 @@ * [chiphogg](https://github.com/chiphogg) * [ciwchris](https://github.com/ciwchris) * [cwarden](https://github.com/cwarden) +* [danderss](https://bitbucket.org/danderss/) +* [danielra](https://github.com/danielra) * [dmedvinsky](https://github.com/dmedvinsky) * [flatcap](https://github.com/flatcap) * [helixbass](https://bitbucket.org/helixbass) +* [hk3380](https://github.com/hk3380) * [hoelzro](https://github.com/hoelzro) +* [inside](https://github.com/inside) +* [jlmuir](https://bitbucket.org/jlmuir/) * [jrib](https://github.com/jrib) * [lheiskan](https://github.com/lheiskan) * [lightningdb](https://github.com/lightningdb) * [manojkumarm](https://github.com/manojkumarm) -* [manojkumarm](https://github.com/manojkumarm) +* [markmontymark](https://github.com/markmontymark) * [markscholtz](https://github.com/markscholtz) * [marlun](https://github.com/marlun) +* [martica](https://github.com/martica) * [mattsacks](https://github.com/mattsacks) +* [mjperrone](https://github.com/mjperrone) * [Mr-Happy](https://github.com/Mr-Happy) * [mrgrubb](https://github.com/mrgrubb) * [NagatoPain](https://github.com/NagatoPain) * [nathanaelkane](https://github.com/nathanaelkane) * [nielsbom](https://github.com/nielsbom) +* [nikkypx](https://github.com/nikkypx) +* [nirenjan](https://github.com/nirenjan) +* [nkalvi](https://github.com/nkalvi) * [nvie](https://github.com/nvie) * [Psycojoker](https://github.com/Psycojoker) +* [rhilenova](https://github.com/rhilenova) * [riceissa](https://github.com/riceissa) * [rodnaph](https://github.com/rodnaph) * [rramsden](https://github.com/rramsden) * [sedm0784](https://github.com/sedm0784) +* [semanticart](https://github.com/semanticart) * [sherrillmix](https://github.com/sherrillmix) * [tapichu](https://github.com/tapichu) * [ZyX-I](https://github.com/ZyX-I) diff -r 2600b031f163 -r 469bfd3284dd chapters/01.markdown --- a/chapters/01.markdown Sun Feb 02 21:42:29 2014 -0800 +++ b/chapters/01.markdown Thu Feb 16 12:49:58 2017 +0000 @@ -60,7 +60,7 @@ Read `:help echom`. -Read `:help messages`. +Read `:help :messages`. Add a line to your `~/.vimrc` file that displays a friendly ASCII-art cat (`>^.^<`) whenever you open Vim. diff -r 2600b031f163 -r 469bfd3284dd chapters/08.markdown --- a/chapters/08.markdown Sun Feb 02 21:42:29 2014 -0800 +++ b/chapters/08.markdown Thu Feb 16 12:49:58 2017 +0000 @@ -47,11 +47,11 @@ very complicated, but in essence it means that all of the following are considered "keyword characters": -* The underscore character (`_`). * All alphabetic ASCII characters, both upper and lower case, and their accented versions. * Any characters with an ASCII value between 48 and 57 (the digits zero through nine). +* The underscore character (`_`). * Any characters with an ASCII value between 192 and 255 (some special ASCII characters). diff -r 2600b031f163 -r 469bfd3284dd chapters/09.markdown --- a/chapters/09.markdown Sun Feb 02 21:42:29 2014 -0800 +++ b/chapters/09.markdown Thu Feb 16 12:49:58 2017 +0000 @@ -35,7 +35,7 @@ with a bit more meat to it. Run the following command: :::vim - :nnoremap " viwa"hbi"lel + :nnoremap " viwa"bi"lel Now *that's* an interesting mapping! First, go ahead and try it out. Enter normal mode, put your cursor over a word in your text and type `"`. Vim @@ -45,7 +45,7 @@ does: :::text - viwa"hbi"lel + viwa"bi"lel * `viw`: visually select the current word * ``: exit visual mode, which leaves the cursor on the last character of @@ -53,7 +53,6 @@ * `a`: enter insert mode *after* the current character * `"`: insert a `"` into the text, because we're in insert mode * ``: return to normal mode -* `h`: move left one character * `b`: move back to the beginning of the word * `i`: enter insert mode *before* the current character * `"`: insert a `"` into the text again diff -r 2600b031f163 -r 469bfd3284dd chapters/11.markdown --- a/chapters/11.markdown Sun Feb 02 21:42:29 2014 -0800 +++ b/chapters/11.markdown Thu Feb 16 12:49:58 2017 +0000 @@ -40,7 +40,7 @@ When you typed `x` in file `bar` Vim couldn't find a mapping that matched it, so it treated it as two commands: `` (which does nothing on -its own) and `x` (the normal command to delete a single character.) +its own) and `x` (the normal command to delete a single character). Local Leader ------------ diff -r 2600b031f163 -r 469bfd3284dd chapters/15.markdown --- a/chapters/15.markdown Sun Feb 02 21:42:29 2014 -0800 +++ b/chapters/15.markdown Thu Feb 16 12:49:58 2017 +0000 @@ -144,7 +144,7 @@ ------------- A good way to keep the multiple ways of creating operator-pending mappings -straight is the remember the following two rules: +straight is to remember the following two rules: * If your operator-pending mapping ends with some text visually selected, Vim will operate on that text. diff -r 2600b031f163 -r 469bfd3284dd chapters/16.markdown --- a/chapters/16.markdown Sun Feb 02 21:42:29 2014 -0800 +++ b/chapters/16.markdown Thu Feb 16 12:49:58 2017 +0000 @@ -161,7 +161,7 @@ Let's look at one more mapping before we move on. Run the following command: :::vim - :onoremap ah :execute "normal! ?^==\\+\r:nohlsearch\rg_vk0" + :onoremap ah :execute "normal! ?^==\\+$\r:nohlsearch\rg_vk0" Try it by putting your cursor in a section's text and typing `cah`. This time Vim will delete not only the heading's text but also the line of equal signs diff -r 2600b031f163 -r 469bfd3284dd chapters/20.markdown --- a/chapters/20.markdown Sun Feb 02 21:42:29 2014 -0800 +++ b/chapters/20.markdown Thu Feb 16 12:49:58 2017 +0000 @@ -25,7 +25,7 @@ Vim has many different scopes for variables, but we need to learn a little more about Vimscript before we can take advantage of the rest. For now, just -remember that when you see a variable that start with a character and a colon +remember that when you see a variable that starts with a character and a colon that it's describing a scoped variable. Exercises diff -r 2600b031f163 -r 469bfd3284dd chapters/23.markdown --- a/chapters/23.markdown Sun Feb 02 21:42:29 2014 -0800 +++ b/chapters/23.markdown Thu Feb 16 12:49:58 2017 +0000 @@ -118,7 +118,7 @@ What did we do here? * First we set the `textwidth` globally to `80`. -* The we ran an if statement that checked if `TextwidthIsTooWide()` was truthy. +* Then we ran an if statement that checked if `TextwidthIsTooWide()` was truthy. * This wound up not being the case, so the `if`'s body wasn't executed. Because we never explicitly returned a value, Vim returned `0` from the diff -r 2600b031f163 -r 469bfd3284dd chapters/26.markdown --- a/chapters/26.markdown Sun Feb 02 21:42:29 2014 -0800 +++ b/chapters/26.markdown Thu Feb 16 12:49:58 2017 +0000 @@ -33,7 +33,7 @@ and `2` respectively. When I said "Number" I really *meant* Number. Vim will *not* coerce strings to -Floats! Try this command to see prove this: +Floats! Try this command to see proof of this: :::vim :echom 10 + "10.10" diff -r 2600b031f163 -r 469bfd3284dd chapters/31.markdown --- a/chapters/31.markdown Sun Feb 02 21:42:29 2014 -0800 +++ b/chapters/31.markdown Thu Feb 16 12:49:58 2017 +0000 @@ -184,7 +184,7 @@ Read `:help pattern-overview` to see the kinds of things Vim regexes support. Stop reading after the character classes. -Read `:help match`. Try running the `:match Error /\v.../` command a few times +Read `:help :match`. Try running the `:match Error /\v.../` command a few times by hand. Edit your `~/.vimrc` file to add a mapping that will use `match` to highlight diff -r 2600b031f163 -r 469bfd3284dd chapters/34.markdown --- a/chapters/34.markdown Sun Feb 02 21:42:29 2014 -0800 +++ b/chapters/34.markdown Thu Feb 16 12:49:58 2017 +0000 @@ -9,11 +9,14 @@ ---------------- By yanking the text into the unnamed register we destroy anything that was -previously in there. +previously in there. Further, by using a visual selection to yank the text in +the case that our operator is applied with a motion, we also destroy any record +of the most recent visual selection. -This isn't very nice to our users, so let's save the contents of that register -before we yank and restore it after we've done. Change the code to look like -this: +This isn't very nice to our users, so let's avoid using a visual selection in +that case and also save the contents of the unnamed register before we yank in +all cases so that we can restore it after we're done. Change the code to look +like this: :::vim nnoremap g :set operatorfunc=GrepOperatorg@ @@ -25,7 +28,7 @@ if a:type ==# 'v' normal! `y elseif a:type ==# 'char' - normal! `[v`]y + normal! `[y`] else return endif @@ -38,6 +41,8 @@ We've added two `let` statements at the top and bottom of the function. The first saves the contents of `@@` into a variable and the second restores it. +Additionally, we've applied yank with a motion rather than a visual selection in +the case that our operator is applied with a motion. Write and source the file. Make sure it works by yanking some text, then pressing `giw` to run our operator, then pressing `p` to paste the text diff -r 2600b031f163 -r 469bfd3284dd chapters/41.markdown --- a/chapters/41.markdown Sun Feb 02 21:42:29 2014 -0800 +++ b/chapters/41.markdown Thu Feb 16 12:49:58 2017 +0000 @@ -53,7 +53,7 @@ Make sure you can get the first couple examples in the pamphlet working in the Potion interpreter and by putting them in a `.pn` file. If it seems like the interpreter isn't working check out [this -issue](https://github.com/fogus/potion/issues/12) for a possible cause. +issue](https://github.com/perl11/potion/issues/12) for a possible cause. -[Potion]: http://fogus.github.com/potion/index.html +[Potion]: http://perl11.github.com/potion/index.html [Io]: http://iolanguage.com/ diff -r 2600b031f163 -r 469bfd3284dd chapters/42.markdown --- a/chapters/42.markdown Sun Feb 02 21:42:29 2014 -0800 +++ b/chapters/42.markdown Thu Feb 16 12:49:58 2017 +0000 @@ -21,7 +21,7 @@ I've been using the word "plugin" to mean "a big ol' hunk of Vimscript that does a bunch of related stuff". Vim has a more specific meaning of "plugin", which -is "a file in `~/.vim/plugins/`". +is "a file in `~/.vim/plugin/`". Most of the time I'll be using the first definition. I'll try to be clear when I mean the second. diff -r 2600b031f163 -r 469bfd3284dd chapters/53.markdown --- a/chapters/53.markdown Sun Feb 02 21:42:29 2014 -0800 +++ b/chapters/53.markdown Thu Feb 16 12:49:58 2017 +0000 @@ -155,7 +155,7 @@ :::vim if !exists("g:potion_command") - let g:potion_command = "/Users/sjl/src/potion/potion" + let g:potion_command = "potion" endif function! PotionCompileAndRunFile() @@ -221,7 +221,7 @@ :::vim if !exists("g:potion_command") - let g:potion_command = "/Users/sjl/src/potion/potion" + let g:potion_command = "potion" endif nnoremap r @@ -256,5 +256,5 @@ Suppose you wanted to programatically force a reload of an autoload file Vim has already loaded, without bothering the user. How might you do this? You may -want to read `:help silent!`. Please don't ever do this in real life. +want to read `:help :silent`. Please don't ever do this in real life. diff -r 2600b031f163 -r 469bfd3284dd chapters/56.markdown --- a/chapters/56.markdown Sun Feb 02 21:42:29 2014 -0800 +++ b/chapters/56.markdown Thu Feb 16 12:49:58 2017 +0000 @@ -59,7 +59,7 @@ determine completions in just about any way you could possibly think of. When you're ready to dive into the rabbit hole of omnicompletion you can start -with `:help omnifunc` and `:help coml-omni` and follow the trail from there. +with `:help omnifunc` and `:help compl-omni` and follow the trail from there. Compiler Support ---------------- diff -r 2600b031f163 -r 469bfd3284dd introduction.markdown --- a/introduction.markdown Sun Feb 02 21:42:29 2014 -0800 +++ b/introduction.markdown Thu Feb 16 12:49:58 2017 +0000 @@ -29,12 +29,6 @@ [leanpub]: http://leanpub.org/learnvimscriptthehardway [paper]: http://bit.ly/lvsthw-paperback [hard]: http://bit.ly/lvsthw-hardcover - -The source code to the book is available [on BitBucket][hg] and [on -GitHub][git]. If you find any mistakes or feel you could improve it feel free -to send a pull request, but I'm retaining the copyright on the book, so if -you're not comfortable with that I understand. - [book]: http://learnvimscriptthehardway.stevelosh.com/ [Vim]: http://www.vim.org/ [hg]: http://bitbucket.org/sjl/learnvimscriptthehardway/