# HG changeset patch # User Steve Losh # Date 1318215611 14400 # Node ID b6dc13ada47e9906aeec2289be09e0240190f468 # Parent 07cfd2d5141f5d370b4992ac2f82caf578a4b3f4 Lolscoping. diff -r 07cfd2d5141f -r b6dc13ada47e chapters/19.markdown --- a/chapters/19.markdown Sun Oct 09 22:49:44 2011 -0400 +++ b/chapters/19.markdown Sun Oct 09 23:00:11 2011 -0400 @@ -127,3 +127,6 @@ Go back through your `~/.vimrc` file and undo the changes. You should never use `let` if `set` will suffice -- it's harder to read. + +Read `:help registers` and look over the list of registers you can read and +write. diff -r 07cfd2d5141f -r b6dc13ada47e chapters/20.markdown --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/chapters/20.markdown Sun Oct 09 23:00:11 2011 -0400 @@ -0,0 +1,36 @@ +Variable Scoping +================ + +So far Vimscript's variables may seem familiar if you come from a dynamic +language like Python or Ruby. For the most part variables act like you would +expect, but Vim adds a certain twist to variables: scoping. + +Open two buffers in separate splits, then go into one of then and run the +following commands: + + :let b:hello = "world" + :echo hello + +As expected, Vim displays "world". Now switch to the other buffer and run the +echo command again: + + :echo hello + +This time Vim throws an error, saying it can't find the variable. + +When we used `b:` in the variable name we told Vim that the variable `hello` +should be local to the current buffer. + +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 +that it's describing a scoped variable. + +Exercises +--------- + +Skim over the list of scopes in `:help internal-variables`. Don't worry if you +don't know what some of them mean, just take a look and keep them in the back of +your mind. + + diff -r 07cfd2d5141f -r b6dc13ada47e outline.org --- a/outline.org Sun Oct 09 22:49:44 2011 -0400 +++ b/outline.org Sun Oct 09 23:00:11 2011 -0400 @@ -18,8 +18,8 @@ ** DONE basic status lines ** DONE a word on shortened command names * part 2 - programming in vimscript -** TODO variables -** variable scopes +** DONE variables +** DONE variable scopes ** conditionals ** comparisons ** functions