Leanpub Header

Skip to main content

Gourmet Vim: A Cookbook

A collection of 200+ Vim recipes

This book contains over 200 practical Vim recipes to help you improve your Vim skill. When you are done reading this, you'll be using Vim like a pro!

Minimum price

$8.99

$12.99

You pay

$12.99

Author earns

$10.39
$

...Or Buy With Credits!

You can get credits monthly with a Reader Membership
PDF
EPUB
WEB
21,678Words
About

About

About the Book

Gourmet Vim: A Cookbook, is a hands-on, practical book to explore efficient editing using the Vim editor.

Text editing is an art.

When programming, we write re-usable codes. Why should it be any different with text editing?

What?

The Gourmet Vim explores the art of efficient text editing using Vim, with 100+ practical examples.

This book packs plenty of tips and tricks of how to do common (and some uncommon) actions in Vim that you can practice immediately. It will give you a jump start to use Vim like a pro (even if you're already one, there is always something new that you can learn). 

When you're done reading this, you'll be better at Vim than ever before.

Why?

I mean, you can actually learn Vim for free from the vimtutor, the help manual, or online articles, so why do you need this cookbook?

If you're just starting Vim, you should explore vimtutor first. Go to your terminal and type vimtutor. It is an excellent tutorial to learn the basics.

The real question is, what happens after you learned the basics? The help manual is too much to read. Online articles are all over the place. The biggest problem when mastering something is that you don't know what you don't know. If you don't know that feature X even exists, you won't search for it. Someone needs to expose you to it. This is where the book comes in. Having a diverse collection of recipes expose you to the features that you may not know exist.

This book is mainly for intermediate and advanced Vim users. Beginners are welcome, but certain knowledge prerequisites would help.

Share this book

Author

About the Author

Igor Irianto

Igor is a software developer in Dallas, TX. He works with Ruby on Rails and various Javascript frameworks.

He lives with his awesome wife and an old border collie golden retriever who likes to sleeps all day.

Contents

Table of Contents

First things

  1. What is this book?
  2. Some naming conventions
  3. Where are the Vimscripts?
  4. Why did you organize this book this way?
  5. How to read this book?

Navigation

  1. Basic Navigations
  2. Toggle Between Files
  3. Navigating Parentheses, Brackets, and Braces
  4. Go to a Different Line
  5. Same-Line Navigation
  6. Screen Adjust
  7. Scroll
  8. Go to the Last…
  9. Go to the Filename Under the Cursor
  10. Go to the Place Where a Text Was Inserted and Enter the Insert Mode

Search

  1. Basic Search
  2. Starting Regex
  3. Stop Searching After the Last Match
  4. Show the Search Count
  5. Moving the Cursor Below or Above the Match
  6. Moving the Cursor to the End of the Match
  7. Search for a Character Enclosed in a Collection
  8. Search for a Keyword at the Start or at the End of the Line
  9. Search for a Line Containing a Starting, Middle, and Ending Keyword
  10. Greedy vs Non-Greedy Search Patterns
  11. Searching for a Keyword Separated by End-of-Line
  12. Search for Either Or
  13. Avoid Typing Forward-Slashes
  14. Marking the Start and End of a Match
  15. Search for the Nth Occurrence in a Line
  16. Search for Any Text Surrounded by a Particular Pattern
  17. Repeat the Last Search
  18. Force a Case-Sensitive Search
  19. Optional Search
  20. Search a Phrase in Multiple Files With Vimgrep
  21. Adding Matches to an Existing Quickfix List
  22. Alias for Digits and Words
  23. More Predefined Characters
  24. Quickly Search for the Word Under the Cursor
  25. Finding a File
  26. Search and Replace in Multiple Files

Command-Line Mode

  1. Command Suggestion
  2. Get the Word Under the Cursor
  3. Faster Delete
  4. Are There More Commands?

File

  1. Buffers, Windows, Tabs
  2. Two Different Write Commands With Similar Syntax
  3. Save a File That Requires a Root Permission
  4. Time Travel
  5. Converting the Current File to an HTML
  6. Open an URL Content
  7. Save a Partial File
  8. Show the Buffers List
  9. Vim Tabs
  10. Save the Current File in a Different Directory
  11. Open the Man Page From Vim
  12. Quitting Vim
  13. Viewing Recent Files
  14. Changing Directory
  15. Executing a Command When Opening a File
  16. Get the Current File Info
  17. Count Words
  18. Delete a File
  19. More Concise Way to Save and Exit
  20. Suspend Vim
  21. Compiling
  22. Persist Local Configuration
  23. Saving a Session

History

  1. Jumping Around Files Quickly
  2. Trace Edited Texts
  3. Search History
  4. Command-Line History
  5. Vim Histories

Insert Mode

  1. Entering Insert Mode
  2. Different Ways to Exit Insert Mode
  3. Paste a Recently Yanked Text
  4. Performing a Quick Calculation
  5. Autocompletion
  6. Executing a Normal Mode Command While in the Insert Mode
  7. Larger Deletes
  8. Scrolling While in the Insert Mode
  9. Insert Special Characters

Layout

  1. Indent and Un-indent Lines
  2. Fix the Indentation of the Entire File
  3. Redraw the Screen
  4. Folding Lines
  5. Cursor Visual Helper

Macros And Registers

  1. Macro Basics
  2. Register Basics
  3. Closer Look At Vim Registers
  4. Clear Up a Register
  5. Output Content From Any Register
  6. Edit an Existing Macro
  7. Use the Blackhole Register to Prevent Register Pollution
  8. See the Content From All Registers
  9. Execute a Macro Programmatically
  10. Quickly Append to an Existing Macro
  11. Quickly Paste From the Numbered Register
  12. Macro Factory
  13. Recursive Macro

Multi-File Operations

  1. Different Ways to Execute a Command In Multiple Files
  2. Substitute In Multiple Files
  3. Execute a Macro in Multiple Files
  4. Limiting the Files to Operate On
  5. Creating an Argument List
  6. Adding to an Argument List

Numbers

  1. Quickly Increment or Decrement a Number on a Line
  2. Incrementing Number By More Than One
  3. Sequentially Increment Multiple Numbers
  4. Substitute and Increment Number
  5. Quickly Generate Incrementing Numbers Anywhere
  6. Get ASCII Value

Repeat

  1. Repeat the Last Command-Line Command
  2. Repeat the Last Change
  3. Repeat the Last Substitute
  4. Repeat the Last Executed Macro
  5. Repeat the Last External Command

Sort

  1. Sorting Lines
  2. External Sort
  3. Reverse Sort

Substitute

  1. Basic Substitution
  2. Case Insensitive Match
  3. Asking For Confirmation Before Substituting
  4. Group Match In Substitution
  5. Use Very Magic to Avoid Escaping Special Characters
  6. Representing the Entire Match
  7. Using the Group Match to Remove Words
  8. Reusing the Previous Search Pattern
  9. Deleting In Substitution Quicker
  10. Using an Expression in a Substitution
  11. Removing Trailing Whitespaces
  12. Add a New Line In Substitution
  13. Repeat the Last Substitute Command
  14. Capitalize the First Letter Of Each Word
  15. Perform a Chain of Substitutes
  16. Repeat the Last Substitute String
  17. Repeat the Last Substitution With the Last Search Pattern and the Last Substitute String
  18. Changing the Delimiter

Global Command

  1. Global Command Basics
  2. Inverse Match
  3. Prepend or Append On Multiple Lines
  4. Global Command Within a Range
  5. Delete Blank and Empty Lines
  6. Running Global Command Between Matching Patterns
  7. Condense Multiple Empty Lines
  8. Reuse the Global Command Search Pattern in the Substitute Command
  9. The Default Command
  10. Use Execute to Run Complex Expressions
  11. Reverse All Lines
  12. Surround All Digits With Double Quotes
  13. Changing the Delimiter
  14. Programmatic Global Command

Tags

  1. What Are Tags?
  2. Setting Up the Tag File
  3. Tags Navigation
  4. Selective Jump
  5. Autocompletion
  6. Automatic Tag Generation

Text Generation

  1. Get a File Content
  2. Get the Current Date
  3. Generate Numbers
  4. Generate IP Addresses
  5. Generate Random Dice Throw
  6. Generate Numbers Horizontally
  7. Transform a Text Into a Numbered List Based On Line Numbers

Text Manipulation

  1. How to Speak Vim
  2. Changing Cases
  3. Swap Two Characters
  4. Replace Mode
  5. Using a Command-Line Command As a Motion to an Operator
  6. Force Motion
  7. Persistent Undo
  8. Undoing In Chunks
  9. Join Lines
  10. Using Terminal Commands

Terminal

  1. Vi Mode
  2. Opening Files
  3. Diffing With Vim
  4. Running Vim Without Plugins or Vimrc
  5. Open Files in Vim as a Result of Another Command
  6. Open Files in Read-Only Mode
  7. Open Vim With Vertical and Horizontal Splits
  8. Generate New Files Programmatically
  9. Passing Text as STDIN to a Command
  10. Using the Terminal From Vim
  11. Check Available Vim Features

Visual Mode

  1. Visual Mode Basics
  2. Insert Text on Multiple Lines
  3. Quickly Reselect the Previous Visual Highlight
  4. Expanding Visual Highlight Bidirectionally
  5. Switching to a Different Visual Mode While in a Visual Mode
  6. Visually Highlight the Last Search Term
  7. Replace Multiple Characters With Visual Selection

Vimrc

  1. Quick Access to Vimrc
  2. Line Numbers
  3. More Helpful Search
  4. Smarter Search Case
  5. Programmatic Options
  6. Create a Custom Command
  7. Conditionally Run Vimrc Settings Based On Directory
  8. Organize Vimrc With the Fold Syntax
  9. Run a Specific Configuration Depending On File Type
  10. Toggle a Boolean Option
  11. Split Vimrc Into Multiple Files
  12. Mapping a New Key
  13. Installing Plugins With Packages
  14. Installing Plugins With Plugin Managers
  15. Trigger Action On Certain Event

Window

  1. Splitting Windows Horizontally and Vertically
  2. Resizing Windows
  3. Close or Zoom the Current Window
  4. Moving the Cursor to Another Windows
  5. Open a New Window
  6. Use Two Windows to Diff Files

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 earned over $14 million writing, 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

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub