Gourmet Vim: A Cookbook
Minimum price
Suggested price

Gourmet Vim: A Cookbook

A collection of 200+ Vim recipes

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?


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.


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.

About the Author

Igor Irianto
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.

Table of Contents

  • First things
    • What is this book?
    • Some naming conventions
    • Where are the Vimscripts?
    • Why did you organize this book this way?
    • How to read this book?
  • Navigation
    • Basic Navigations
    • Toggle Between Files
    • Navigating Parentheses, Brackets, and Braces
    • Go to a Different Line
    • Same-Line Navigation
    • Screen Adjust
    • Scroll
    • Go to the Last…
    • Go to the Filename Under the Cursor
    • Go to the Place Where a Text Was Inserted and Enter the Insert Mode
  • Search
    • Basic Search
    • Starting Regex
    • Stop Searching After the Last Match
    • Show the Search Count
    • Moving the Cursor Below or Above the Match
    • Moving the Cursor to the End of the Match
    • Search for a Character Enclosed in a Collection
    • Search for a Keyword at the Start or at the End of the Line
    • Search for a Line Containing a Starting, Middle, and Ending Keyword
    • Greedy vs Non-Greedy Search Patterns
    • Searching for a Keyword Separated by End-of-Line
    • Search for Either Or
    • Avoid Typing Forward-Slashes
    • Marking the Start and End of a Match
    • Search for the Nth Occurrence in a Line
    • Search for Any Text Surrounded by a Particular Pattern
    • Repeat the Last Search
    • Force a Case-Sensitive Search
    • Optional Search
    • Search a Phrase in Multiple Files With Vimgrep
    • Adding Matches to an Existing Quickfix List
    • Alias for Digits and Words
    • More Predefined Characters
    • Quickly Search for the Word Under the Cursor
    • Finding a File
    • Search and Replace in Multiple Files
  • Command-Line Mode
    • Command Suggestion
    • Get the Word Under the Cursor
    • Faster Delete
    • Are There More Commands?
  • File
    • Buffers, Windows, Tabs
    • Two Different Write Commands With Similar Syntax
    • Save a File That Requires a Root Permission
    • Time Travel
    • Converting the Current File to an HTML
    • Open an URL Content
    • Save a Partial File
    • Show the Buffers List
    • Vim Tabs
    • Save the Current File in a Different Directory
    • Open the Man Page From Vim
    • Quitting Vim
    • Viewing Recent Files
    • Changing Directory
    • Executing a Command When Opening a File
    • Get the Current File Info
    • Count Words
    • Delete a File
    • More Concise Way to Save and Exit
    • Suspend Vim
    • Compiling
    • Persist Local Configuration
    • Saving a Session
  • History
    • Jumping Around Files Quickly
    • Trace Edited Texts
    • Search History
    • Command-Line History
    • Vim Histories
  • Insert Mode
    • Entering Insert Mode
    • Different Ways to Exit Insert Mode
    • Paste a Recently Yanked Text
    • Performing a Quick Calculation
    • Autocompletion
    • Executing a Normal Mode Command While in the Insert Mode
    • Larger Deletes
    • Scrolling While in the Insert Mode
    • Insert Special Characters
  • Layout
    • Indent and Un-indent Lines
    • Fix the Indentation of the Entire File
    • Redraw the Screen
    • Folding Lines
    • Cursor Visual Helper
  • Macros And Registers
    • Macro Basics
    • Register Basics
    • Closer Look At Vim Registers
    • Clear Up a Register
    • Output Content From Any Register
    • Edit an Existing Macro
    • Use the Blackhole Register to Prevent Register Pollution
    • See the Content From All Registers
    • Execute a Macro Programmatically
    • Quickly Append to an Existing Macro
    • Quickly Paste From the Numbered Register
    • Macro Factory
    • Recursive Macro
  • Multi-File Operations
    • Different Ways to Execute a Command In Multiple Files
    • Substitute In Multiple Files
    • Execute a Macro in Multiple Files
    • Limiting the Files to Operate On
    • Creating an Argument List
    • Adding to an Argument List
  • Numbers
    • Quickly Increment or Decrement a Number on a Line
    • Incrementing Number By More Than One
    • Sequentially Increment Multiple Numbers
    • Substitute and Increment Number
    • Quickly Generate Incrementing Numbers Anywhere
    • Get ASCII Value
  • Repeat
    • Repeat the Last Command-Line Command
    • Repeat the Last Change
    • Repeat the Last Substitute
    • Repeat the Last Executed Macro
    • Repeat the Last External Command
  • Sort
    • Sorting Lines
    • External Sort
    • Reverse Sort
  • Substitute
    • Basic Substitution
    • Case Insensitive Match
    • Asking For Confirmation Before Substituting
    • Group Match In Substitution
    • Use Very Magic to Avoid Escaping Special Characters
    • Representing the Entire Match
    • Using the Group Match to Remove Words
    • Reusing the Previous Search Pattern
    • Deleting In Substitution Quicker
    • Using an Expression in a Substitution
    • Removing Trailing Whitespaces
    • Add a New Line In Substitution
    • Repeat the Last Substitute Command
    • Capitalize the First Letter Of Each Word
    • Perform a Chain of Substitutes
    • Repeat the Last Substitute String
    • Repeat the Last Substitution With the Last Search Pattern and the Last Substitute String
    • Changing the Delimiter
  • Global Command
    • Global Command Basics
    • Inverse Match
    • Prepend or Append On Multiple Lines
    • Global Command Within a Range
    • Delete Blank and Empty Lines
    • Running Global Command Between Matching Patterns
    • Condense Multiple Empty Lines
    • Reuse the Global Command Search Pattern in the Substitute Command
    • The Default Command
    • Use Execute to Run Complex Expressions
    • Reverse All Lines
    • Surround All Digits With Double Quotes
    • Changing the Delimiter
    • Programmatic Global Command
  • Tags
    • What Are Tags?
    • Setting Up the Tag File
    • Tags Navigation
    • Selective Jump
    • Autocompletion
    • Automatic Tag Generation
  • Text Generation
    • Get a File Content
    • Get the Current Date
    • Generate Numbers
    • Generate IP Addresses
    • Generate Random Dice Throw
    • Generate Numbers Horizontally
    • Transform a Text Into a Numbered List Based On Line Numbers
  • Text Manipulation
    • How to Speak Vim
    • Changing Cases
    • Swap Two Characters
    • Replace Mode
    • Using a Command-Line Command As a Motion to an Operator
    • Force Motion
    • Persistent Undo
    • Undoing In Chunks
    • Join Lines
    • Using Terminal Commands
  • Terminal
    • Vi Mode
    • Opening Files
    • Diffing With Vim
    • Running Vim Without Plugins or Vimrc
    • Open Files in Vim as a Result of Another Command
    • Open Files in Read-Only Mode
    • Open Vim With Vertical and Horizontal Splits
    • Generate New Files Programmatically
    • Passing Text as STDIN to a Command
    • Using the Terminal From Vim
    • Check Available Vim Features
  • Visual Mode
    • Visual Mode Basics
    • Insert Text on Multiple Lines
    • Quickly Reselect the Previous Visual Highlight
    • Expanding Visual Highlight Bidirectionally
    • Switching to a Different Visual Mode While in a Visual Mode
    • Visually Highlight the Last Search Term
    • Replace Multiple Characters With Visual Selection
  • Vimrc
    • Quick Access to Vimrc
    • Line Numbers
    • More Helpful Search
    • Smarter Search Case
    • Programmatic Options
    • Create a Custom Command
    • Conditionally Run Vimrc Settings Based On Directory
    • Organize Vimrc With the Fold Syntax
    • Run a Specific Configuration Depending On File Type
    • Toggle a Boolean Option
    • Split Vimrc Into Multiple Files
    • Mapping a New Key
    • Installing Plugins With Packages
    • Installing Plugins With Plugin Managers
    • Trigger Action On Certain Event
  • Window
    • Splitting Windows Horizontally and Vertically
    • Resizing Windows
    • Close or Zoom the Current Window
    • Moving the Cursor to Another Windows
    • Open a New Window
    • 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...

80% Royalties. Earn $16 on a $20 book.

We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course 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

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