# HG changeset patch # User Steve Losh # Date 1365038179 14400 # Node ID 436f8ce22479db82223fb871392dc96b3be212d9 # Parent b0ca11bfb7a899ade473a81c924b3669880f3d57 Proof 09-12. diff -r b0ca11bfb7a8 -r 436f8ce22479 chapters/09.markdown --- a/chapters/09.markdown Wed Apr 03 20:58:01 2013 -0400 +++ b/chapters/09.markdown Wed Apr 03 21:16:19 2013 -0400 @@ -3,7 +3,7 @@ I know we've talked a lot about mappings so far, but we're going to practice them again now. Mappings are one of the easiest and fastest ways to make your -Vim editing more productive, so it's good to focus on them quite a bit. +Vim editing more productive so it's good to focus on them quite a bit. One concept that has showed up in several examples but that we haven't explicitly talked about is mapping a sequence of multiple keys. @@ -90,3 +90,4 @@ Add all of these mappings to your `~/.vimrc` file, making sure to use your "edit my `~/.vimrc`" and "source my `~/.vimrc`" mappings to do so. + diff -r b0ca11bfb7a8 -r 436f8ce22479 chapters/10.markdown --- a/chapters/10.markdown Wed Apr 03 20:58:01 2013 -0400 +++ b/chapters/10.markdown Wed Apr 03 21:16:19 2013 -0400 @@ -49,14 +49,14 @@ :inoremap This effectively disables the escape key in insert mode by telling Vim to -perform `` (no operation) instead. +perform `` (no operation) instead. Now you *have* to use your `jk` mapping +to exit insert mode. -Now you *have* to use your `jk` mapping to exit insert mode. At first you'll -forget, type escape and start trying to do something in normal mode and you'll -wind up with stray characters in your text. It will be frustrating, but if you -stick with it you'll be surprised at how fast your mind and fingers absorb the -new mapping. Within an hour or two you won't be accidentally hitting escape any -more. +At first you'll forget, type escape and start trying to do something in normal +mode and you'll wind up with stray characters in your text. It will be +frustrating, but if you stick with it you'll be surprised at how fast your mind +and fingers absorb the new mapping. Within an hour or two you won't be +accidentally hitting escape any more. This idea applies to any new mapping you create to replace an old one, and even to life in general. When you want to change a habit, make it harder or @@ -80,3 +80,4 @@ If you still use the arrow keys in insert mode, map them to `` there too. The right way to use Vim is to get out of insert mode as soon as you can and use normal mode to move around. + diff -r b0ca11bfb7a8 -r 436f8ce22479 chapters/11.markdown --- a/chapters/11.markdown Wed Apr 03 20:58:01 2013 -0400 +++ b/chapters/11.markdown Wed Apr 03 21:16:19 2013 -0400 @@ -2,7 +2,7 @@ ================================= Now we're going to take a few minutes to revisit three things we've already -talked about: mappings, abbreviations, and options, but with a twist: we're +talked about: mappings, abbreviations, and options, but with a twist. We're going to set each of them in a single buffer at a time. The true power of this idea will become apparent in the next chapter, but we @@ -22,7 +22,7 @@ :nnoremap x dd Now stay in file `foo`, make sure you're in normal mode, and type `d`. -Vim will delete a line. This is nothing new to us. +Vim will delete a line. This is nothing new. Still in file `foo`, type `x`. Vim will delete a line again. This makes sense because we mapped `x` to `dd` as well. @@ -30,7 +30,7 @@ Now move over to file `bar`. While in normal mode, type `d`. Again, Vim deletes the current line. Nothing surprising here either. -Now for the twist: while still in file `bar` type `x`. +Now for the twist: while still in file `bar`, type `x`. Instead of deleting the entire line, Vim just deleted a single character! What happened? diff -r b0ca11bfb7a8 -r 436f8ce22479 chapters/12.markdown --- a/chapters/12.markdown Wed Apr 03 20:58:01 2013 -0400 +++ b/chapters/12.markdown Wed Apr 03 21:16:19 2013 -0400 @@ -121,7 +121,7 @@ This is almost like our last command, except it will also reindent the code whenever we *read* an HTML file as well as when we write it. This could be -useful if you have coworkers that don't indent their HTML well. +useful if you have coworkers that don't indent their HTML nicely. A common idiom in Vim scripting is to pair the `BufRead` and `BufNewFile` events together to run a command whenever you open a certain kind of file, regardless @@ -142,8 +142,8 @@ following commands: :::vim - :autocmd FileType javascript nnoremap c I// - :autocmd FileType python nnoremap c I# + :autocmd FileType javascript nnoremap c I// + :autocmd FileType python nnoremap c I# Open a Javascript file (a file that ends in `.js`), pick a line and type `c`. This will comment out the line. @@ -160,15 +160,12 @@ think about moving to the beginning of the line and adding a comment character we can simply think "comment this line". -You may have noticed that this mapping leaves us in insert mode. Unfortunately -we can't fix that just yet, but we'll get to it later in the book! - Exercises --------- Skim `:help autocmd-events` to see a list of all the events you can bind -autocommands to. You don't need to memorize each one right now; just try to get -a feel for the kinds of things you can do. +autocommands to. You don't need to memorize each one right now. Just try to +get a feel for the kinds of things you can do. Create a few `FileType` autocommands that use `setlocal` to set options for your favorite filetypes just the way you like them. Some options you might like to diff -r b0ca11bfb7a8 -r 436f8ce22479 style.txt --- a/style.txt Wed Apr 03 20:58:01 2013 -0400 +++ b/style.txt Wed Apr 03 21:16:19 2013 -0400 @@ -2,6 +2,8 @@ If you type `:echom "Hello!"` Vim will output `Hello`. +Filenames should also be in backticks. + Key mappings should be lowercase. nnoremap ...