Learn Vimscript the Hard Way
Learn Vimscript the Hard Way
About the Book
LVSTHW is a book about customizing the Vim editor. It's freely available online, but you can buy an ebook copy here.
Table of Contents
- Preface
- Acknowledgements
- Prerequisites
- Creating a Vimrc File
- 1 Echoing Messages
- 1.1 Persistent Echoing
- 1.2 Comments
- 1.3 Exercises
- 2 Setting Options
- 2.1 Boolean Options
- 2.2 Toggling Boolean Options
- 2.3 Checking Options
- 2.4 Options with Values
- 2.5 Setting Multiple Options at Once
- 2.6 Exercises
- 3 Basic Mapping
- 3.1 Special Characters
- 3.2 Commenting
- 3.3 Exercises
- 4 Modal Mapping
- 4.1 Muscle Memory
- 4.2 Insert Mode
- 4.3 Exercises
- 5 Strict Mapping
- 5.1 Recursion
- 5.2 Side Effects
- 5.3 Nonrecursive Mapping
- 5.4 Exercises
- 6 Leaders
- 6.1 Mapping Key Sequences
- 6.2 Leader
- 6.3 Local Leader
- 6.4 Exercises
- 7 Editing Your Vimrc
- 7.1 Editing Mapping
- 7.2 Sourcing Mapping
- 7.3 Exercises
- 8 Abbreviations
- 8.1 Keyword Characters
- 8.2 More Abbreviations
- 8.3 Why Not Use Mappings?
- 8.4 Exercises
- 9 More Mappings
- 9.1 A More Complicated Mapping
- 9.2 Exercises
- 10 Training Your Fingers
- 10.1 Learning the Map
- 10.2 Exercises
- 11 Buffer-Local Options and Mappings
- 11.1 Mappings
- 11.2 Local Leader
- 11.3 Settings
- 11.4 Shadowing
- 11.5 Exercises
- 12 Autocommands
- 12.1 Autocommand Structure
- 12.2 Another Example
- 12.3 Multiple Events
- 12.4 FileType Events
- 12.5 Exercises
- 13 Buffer-Local Abbreviations
- 13.1 Autocommands and Abbreviations
- 13.2 Exercises
- 14 Autocommand Groups
- 14.1 The Problem
- 14.2 Grouping Autocommands
- 14.3 Clearing Groups
- 14.4 Using Autocommands in Your Vimrc
- 14.5 Exercises
- 15 Operator-Pending Mappings
- 15.1 Movement Mappings
- 15.2 Changing the Start
- 15.3 General Rules
- 15.4 Exercises
- 16 More Operator-Pending Mappings
- 16.1 Normal
- 16.2 Execute
- 16.3 Results
- 16.4 Exercises
- 17 Status Lines
- 17.1 Width and Padding
- 17.2 General Format
- 17.3 Splitting
- 17.4 Exercises
- 18 Responsible Coding
- 18.1 Commenting
- 18.2 Grouping
- 18.3 Short Names
- 18.4 Exercises
- 19 Variables
- 19.1 Options as Variables
- 19.2 Local Options
- 19.3 Registers as Variables
- 19.4 Exercises
- 20 Variable Scoping
- 20.1 Exercises
- 21 Conditionals
- 21.1 Multiple-Line Statements
- 21.2 Basic If
- 21.3 Else and Elseif
- 21.4 Exercises
- 22 Comparisons
- 22.1 Case Sensitivity
- 22.2 Code Defensively
- 22.3 Exercises
- 23 Functions
- 23.1 Calling Functions
- 23.2 Implicit Returning
- 23.3 Exercises
- 24 Function Arguments
- 24.1 Varargs
- 24.2 Assignment
- 24.3 Exercises
- 25 Numbers
- 25.1 Number Formats
- 25.2 Float Formats
- 25.3 Coercion
- 25.4 Division
- 25.5 Exercises
- 26 Strings
- 26.1 Concatenation
- 26.2 Special Characters
- 26.3 Literal Strings
- 26.4 Truthiness
- 26.5 Exercises
- 27 String Functions
- 27.1 Length
- 27.2 Splitting
- 27.3 Joining
- 27.4 Lower and Upper Case
- 27.5 Exercises
- 28 Execute
- 28.1 Basic Execution
- 28.2 Is Execute Dangerous?
- 28.3 Exercises
- 29 Normal
- 29.1 Avoiding Mappings
- 29.2 Special Characters
- 29.3 Exercises
- 29.4 Extra Credit
- 30 Execute Normal!
- 30.1 Exercises
- 31 Basic Regular Expressions
- 31.1 Highlighting
- 31.2 Searching
- 31.3 Magic
- 31.4 Literal Strings
- 31.5 Very Magic
- 31.6 Exercises
- 32 Case Study: Grep Operator, Part One
- 32.1 Grep
- 32.2 Usage
- 32.3 A Preliminary Sketch
- 32.4 The Search Term
- 32.5 Escaping Shell Command Arguments
- 32.6 Cleanup
- 32.7 Exercises
- 33 Case Study: Grep Operator, Part Two
- 33.1 Create a File
- 33.2 Skeleton
- 33.3 Visual Mode
- 33.4 Motion Types
- 33.5 Copying the Text
- 33.6 Escaping the Search Term
- 33.7 Running Grep
- 33.8 Exercises
- 34 Case Study: Grep Operator, Part Three
- 34.1 Saving Registers
- 34.2 Namespacing
- 34.3 Exercises
- 35 Lists
- 35.1 Indexing
- 35.2 Slicing
- 35.3 Concatenation
- 35.4 List Functions
- 35.5 Exercises
- 36 Looping
- 36.1 For Loops
- 36.2 While Loops
- 36.3 Exercises
- 37 Dictionaries
- 37.1 Indexing
- 37.2 Assigning and Adding
- 37.3 Removing Entries
- 37.4 Dictionary Functions
- 37.5 Exercises
- 38 Toggling
- 38.1 Toggling Options
- 38.2 Toggling Other Things
- 38.3 Improvements
- 38.4 Restoring Windows/Buffers
- 38.5 Exercises
- 39 Functional Programming
- 39.1 Immutable Data Structures
- 39.2 Functions as Variables
- 39.3 Higher-Order Functions
- 39.4 Performance
- 39.5 Exercises
- 40 Paths
- 40.1 Absolute Paths
- 40.2 Listing Files
- 40.3 Exercises
- 41 Creating a Full Plugin
- 41.1 Potion
- 41.2 Exercises
- 42 Plugin Layout in the Dark Ages
- 42.1 Basic Layout
- 42.2 ~/.vim/colors/
- 42.3 ~/.vim/plugin/
- 42.4 ~/.vim/ftdetect/
- 42.5 ~/.vim/ftplugin/
- 42.6 ~/.vim/indent/
- 42.7 ~/.vim/compiler/
- 42.8 ~/.vim/after/
- 42.9 ~/.vim/autoload/
- 42.10 ~/.vim/doc/
- 42.11 Exercises
- 43 A New Hope: Plugin Layout with Pathogen
- 43.1 Runtimepath
- 43.2 Pathogen
- 43.3 Being Pathogen-Compatible
- 43.4 Exercises
- 44 Detecting Filetypes
- 44.1 Detecting Potion Files
- 44.2 Exercises
- 45 Basic Syntax Highlighting
- 45.1 Highlighting Keywords
- 45.2 Highlighting Functions
- 45.3 Exercises
- 46 Advanced Syntax Highlighting
- 46.1 Highlighting Comments
- 46.2 Highlighting Operators
- 46.3 Exercises
- 47 Even More Advanced Syntax Highlighting
- 47.1 Highlighting Strings
- 47.2 Exercises
- 48 Basic Folding
- 48.1 Types of Folding
- 48.2 Potion Folding
- 48.3 Exercises
- 49 Advanced Folding
- 49.1 Folding Theory
- 49.2 First: Make a Plan
- 49.3 Getting Started
- 49.4 Expr Folding
- 49.5 Blank Lines
- 49.6 Special Foldlevels
- 49.7 An Indentation Level Helper
- 49.8 One More Helper
- 49.9 Finishing the Fold Function
- 49.10 Review
- 49.11 Exercises
- 50 Section Movement Theory
- 50.1 Nroff Files
- 50.2 Braces
- 50.3 Exercises
- 51 Potion Section Movement
- 51.1 Custom Mappings
- 51.2 Using a Function
- 51.3 Base Movement
- 51.4 Top Level Text Sections
- 51.5 Search Flags
- 51.6 Function Definitions
- 51.7 Visual Mode
- 51.8 Why Bother?
- 51.9 Exercises
- 52 External Commands
- 52.1 Compiling
- 52.2 Bang!
- 52.3 Displaying Bytecode
- 52.4 system()
- 52.5 Scratch Splits
- 52.6 Exercises
- 52.7 Extra Credit
- 52.8 More Extra Credit
- 53 Autoloading
- 53.1 How Autoload Works
- 53.2 Experimenting
- 53.3 What to Autoload
- 53.4 Adding Autoloading to the Potion Plugin
- 53.5 Exercises
- 54 Documentation
- 54.1 How Documentation Works
- 54.2 Help Header
- 54.3 What to Document
- 54.4 Table of Contents
- 54.5 Sections
- 54.6 Examples
- 54.7 Write!
- 54.8 Exercises
- 55 Distribution
- 55.1 Hosting
- 55.2 Documentation
- 55.3 Publicity
- 55.4 Exercises
- 56 What Now?
- 56.1 Color Schemes
- 56.2 The Command Command
- 56.3 runtimepath
- 56.4 Omnicomplete
- 56.5 Compiler Support
- 56.6 Other Languages
- 56.7 Vim’s Documentation
- 56.8 Exercises
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.
You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!
So, there's no reason not to click the Add to Cart button, is there?
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earnedover $13 millionwriting, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them