f28776bb4531

Holy shit.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Thu, 04 Apr 2013 01:35:49 -0400
parents 4d881a6b4d15
children 56683eb09ecc
branches/tags (none)
files chapters/32.markdown chapters/51.markdown chapters/54.markdown introduction.markdown

Changes

--- a/chapters/32.markdown	Wed Apr 03 23:09:31 2013 -0400
+++ b/chapters/32.markdown	Thu Apr 04 01:35:49 2013 -0400
@@ -180,7 +180,7 @@
 command:
 
     :::vim
-    :nnoremap <leader>g :execute "grep -R " . shellescape(expand("<cWORD>")) . " ."<cr>
+    :nnoremap <leader>g :exe "grep -R " . shellescape(expand("<cWORD>")) . " ."<cr>
 
 Try it out.  This mapping won't break if the word we're searching for happens to
 contain strange characters.
--- a/chapters/51.markdown	Wed Apr 03 23:09:31 2013 -0400
+++ b/chapters/51.markdown	Thu Apr 04 01:35:49 2013 -0400
@@ -96,11 +96,22 @@
     function! s:NextSection(type, backwards)
     endfunction
 
-    noremap <script> <buffer> <silent> ]] :call <SID>NextSection(1, 0)<cr>
-    noremap <script> <buffer> <silent> [[ :call <SID>NextSection(1, 1)<cr>
+    noremap <script> <buffer> <silent> ]]
+            \ :call <SID>NextSection(1, 0)<cr>
+
+    noremap <script> <buffer> <silent> [[
+            \ :call <SID>NextSection(1, 1)<cr>
 
-    noremap <script> <buffer> <silent> ][ :call <SID>NextSection(2, 0)<cr>
-    noremap <script> <buffer> <silent> [] :call <SID>NextSection(2, 1)<cr>
+    noremap <script> <buffer> <silent> ][
+            \ :call <SID>NextSection(2, 0)<cr>
+
+    noremap <script> <buffer> <silent> []
+            \ :call <SID>NextSection(2, 1)<cr>
+
+I used Vimscript's long line continuation feature here because the lines were
+getting a bit long for my taste.  Notice how the backslash to escape long lines
+comes at the *beginning* of the second line.  Read `:help line-continuation` for
+more information.
 
 Notice that we're using `<SID>` and a script-local function to avoid polluting
 the global namespace with our helper function.
@@ -319,21 +330,33 @@
 argument:
 
     :::vim
-    noremap  <script> <buffer> <silent> ]] :call <SID>NextSection(1, 0, 0)<cr>
-    noremap  <script> <buffer> <silent> [[ :call <SID>NextSection(1, 1, 0)<cr>
+    noremap <script> <buffer> <silent> ]]
+            \ :call <SID>NextSection(1, 0, 0)<cr>
+
+    noremap <script> <buffer> <silent> [[
+            \ :call <SID>NextSection(1, 1, 0)<cr>
 
-    noremap  <script> <buffer> <silent> ][ :call <SID>NextSection(2, 0, 0)<cr>
-    noremap  <script> <buffer> <silent> [] :call <SID>NextSection(2, 1, 0)<cr>
+    noremap <script> <buffer> <silent> ][
+            \ :call <SID>NextSection(2, 0, 0)<cr>
+
+    noremap <script> <buffer> <silent> []
+            \ :call <SID>NextSection(2, 1, 0)<cr>
 
 Nothing too complex there.  Now let's add the visual mode mappings as the final
 piece of the puzzle:
 
     :::vim
-    vnoremap <script> <buffer> <silent> ]] :<c-u>call <SID>NextSection(1, 0, 1)<cr>
-    vnoremap <script> <buffer> <silent> [[ :<c-u>call <SID>NextSection(1, 1, 1)<cr>
+    vnoremap <script> <buffer> <silent> ]]
+            \ :<c-u>call <SID>NextSection(1, 0, 1)<cr>
+
+    vnoremap <script> <buffer> <silent> [[
+            \ :<c-u>call <SID>NextSection(1, 1, 1)<cr>
 
-    vnoremap <script> <buffer> <silent> ][ :<c-u>call <SID>NextSection(2, 0, 1)<cr>
-    vnoremap <script> <buffer> <silent> [] :<c-u>call <SID>NextSection(2, 1, 1)<cr>
+    vnoremap <script> <buffer> <silent> ][
+            \ :<c-u>call <SID>NextSection(2, 0, 1)<cr>
+
+    vnoremap <script> <buffer> <silent> []
+            \ :<c-u>call <SID>NextSection(2, 1, 1)<cr>
 
 These mappings all pass `1` for the `visual` argument to tell Vim to reselect
 the last selection before performing the movement.  They also use the `<c-u>`
--- a/chapters/54.markdown	Wed Apr 03 23:09:31 2013 -0400
+++ b/chapters/54.markdown	Thu Apr 04 01:35:49 2013 -0400
@@ -145,8 +145,8 @@
 the `potion.txt` file:
 
     :::text
-    ==============================================================================
-    CONTENTS                                                      *PotionContents*
+    ====================================================================
+    CONTENTS                                            *PotionContents*
 
         1. Usage ................ |PotionUsage|
         2. Mappings ............. |PotionMappings|
@@ -179,11 +179,11 @@
 You can create section headers like this:
 
     :::text
-    ==============================================================================
-    Section 1: Usage                                                 *PotionUsage*
+    ====================================================================
+    Section 1: Usage                                       *PotionUsage*
 
-    This plugin with automatically provide syntax highlighting for Potion files
-    (files ending in .pn).
+    This plugin with automatically provide syntax highlighting for
+    Potion files (files ending in .pn).
 
     It also...
 
--- a/introduction.markdown	Wed Apr 03 23:09:31 2013 -0400
+++ b/introduction.markdown	Thu Apr 04 01:35:49 2013 -0400
@@ -18,6 +18,17 @@
 can redistribute it as long as you don't make any changes and don't charge for
 it.
 
+The book will always be free to read online.
+
+You can buy an ebook (PDF, epub, mobi) version for $8 on Leanpub at:
+<http://leanpub.org/learnvimscriptthehardway>
+
+You can buy a paperback copy for $20 on Lulu at:
+<http://bit.ly/lvsthw-paperback>
+
+You can buy a hardcover copy for $40 on Lulu at:
+<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
@@ -29,3 +40,4 @@
 [git]: http://github.com/sjl/learnvimscriptthehardway/
 [license]: http://learnvimscriptthehardway.stevelosh.com/license.html
 [leanpub]: http://leanpub.com/learnvimscriptthehardway
+[lulu]: http://lulu.com/learnvimscriptthehardway