Practical Vim
Edit Text at the Speed of Thought
by Drew Neil
Version: P1.0 (September 2012)
Copyright 2012 The Pragmatic Bookshelf. This book is licensed tothe individual who purchased it. We don't copy-protect itbecause that would limit your ability to use it for yourown purposes. Please don't break this trustyou can use this across all of your devices but please do not share this copywith other members of your team, with friends, or via file sharing services. Thanks.
Dave & Andy.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and The Pragmatic Programmers, LLC was aware of a trademark claim, the designations have been printed in initial capital letters or in all capitals. The Pragmatic Starter Kit, The Pragmatic Programmer, Pragmatic Programming, Pragmatic Bookshelf and the linking g device are trademarks of The Pragmatic Programmers, LLC.
Every precaution was taken in the preparation of this book. However, the publisher assumes no responsibility for errors or omissions, or for damages that may result from the use of information (including program listings) contained herein.
Our Pragmatic courses, workshops, and other products can help you and your team create better software and have more fun. For more information, as well as the latest Pragmatic titles, please visit us at http://pragprog.com.
Table of Contents
Index and Navigate Source Code with ctags |
Compile Code and Navigate Errors with the Quickfix List |
Search Project-Wide with grep, vimgrep, and Others |
Copyright 2012, The Pragmatic Bookshelf.
What readers are saying about Practical Vim
Ive learned more about Vim by reading this book than I have from any other resource.
Robert Evans |
Software Engineer, Code Wranglers |
After reading a couple of chapters of Practical Vim , I realized how little I knew. From intermediate to beginner in thirty minutes!
Henrik Nyh |
Software Engineer |
Practical Vim continues to change what I believe a text editor can do.
John P. Daigle |
Developer, ThoughtWorks, Inc. |
Drew has continued the wonderful work he has done with Vimcasts in this book, a must-read for anyone serious about Vim.
Anders Janmyr |
Developer, Jayway |
Practical Vim bridges the gap between the official documentation and how to really use Vim. After reading a few chapters, I switched to using Vim as my default editor. Ive never looked back.
Javier Collado |
QA Automation Engineer, Canonical Ltd. |
Drew Neil does more than show the right tool for the job. He paces the narrative, laying out the philosophy behind each decision. Instead of expecting you to memorize everything, Practical Vim teaches you to think with Vim under your fingertips.
Mislav Marohnic |
Consultant |
Ive been using Vim for server maintenance for more than fifteen years now, but Ive only recently started using it for software development. I thought I knew Vim, but Practical Vim has massively improved my code-wrangling productivity.
Graeme Mathieson |
Software Engineer, Rubaidh Ltd. |
Practical Vim made me realize how much there is still to learn about Vim. Every single tip can be easily and immediately applied to your workflow and will improve your productivity manifold.
Mathias Meyer |
Author, Riak Handbook |
Practical Vim is the ultimate treasure chest when it comes to Vim knowledge. Ive used Vim daily for over two years now, and this book has been nothing short of a revelation for me.
Felix Geisendrfer |
Cofounder, Transloadit |
Acknowledgments
Thanks to Bram Moolenaar for creating Vim and to all those who have contributed to its development. Its a timeless piece of software, and I look forward to growing with it.
Thanks to everyone at the Pragmatic Bookshelf for working together to make this book the best that it could be. Special thanks to Kay Keppler, my developmental editor, for coaching me as a writer and for helping to shape this book, despite its growing pains and my occasional tantrums. Id also like to thank David Kelly for his adept handling of my unusual formatting requests.
Practical Vim didnt start out as a recipe book, but Susannah Pfalzer recognized that it would work best in this format. It was painful to have to rewrite so much, but in doing so I produced a draft that I was happy with for the first time. Susannah knows whats best, and I thank her for sharing that insight.
Thanks to Dave Thomas and Andy Hunt for creating the Pragmatic Bookshelf. I wouldnt want to be represented by any other publisher, and Im honored to be listed alongside the other titles in their catalog.
Practical Vim wouldnt have been possible without my technical reviewers. Each of you contributed something and helped to shape the book. Id like to thank Adam McCrea, Alan Gardner, Alex Khan, Ali Alwasity, Anders Janmyr, Andrew Donaldson, Angus Neil, Charlie Tanksley, Ches Martin, Daniel Bretoi, David Morris, Denis Gorin, Elyzer Mendes Rezende, Erik St. Martin, Federico Galassi, Felix Geisendrfer, Florian Vallen, Graeme Mathieson, Hans Hasselberg, Henrik Nyh, Javier Collado, Jeff Holland, Josh Sullivan, Joshua Flanagan, Kana Natsuno, Kent Frazier, Luis Merino, Mathias Meyer, Matt Southerden, Mislav Marohnic, Mitch Guthrie, Morgan Prior, Paul Barry, Peter Aronoff, Peter Rihn, Philip Roberts, Robert Evans, Ryan Stenhouse, Steven! Ragnark, Tibor Simic, Tim Chase, Tim Pope, Tim Tyrrell, and Tobias Sailer.
As a whole, Id like to thank the Vim community for sharing their insights across the Internet. I learned many of the tips in this book by reading the Vim tag on StackOverflow and by following the vim_use mailing list.
Tim Popes rails.vim plugin was instrumental in convincing me to take Vim seriously, and many of his other plugins have become essential parts of my setup. Ive also gained insight by using the plugins of Kana Natsuno, whose custom text objects are some of the best extensions to Vims core functionality that Ive come across. Thank you to both for sharpening the saw so that the rest of us can benefit.
Thanks to Joe Rozner for providing the wakeup source code that I used to introduce the :make
command. Thanks to Oleg Efimov for his quick response to nodelint issues. Thanks to Ben Cormack for illustrating the robots and ninjas.
In January 2012, we moved to Berlin, where the tech community inspired me to complete this book. Id like to thank Gregor Schmidt for founding the Vim Berlin user group and Jan Schulz-Hofen for hosting our meetups. The opportunity to speak to fellow Vim users really helped me to get my thoughts in order, so Im grateful to everyone who attended the Vim Berlin meetings. Thank you to Daniel and Nina Holle for subletting your home to us. It was a wonderful place to live and a productive environment in which to work.
In March 2011, I needed surgery to clear adhesions that were obstructing my bowel. Unlucky for me, I was a long way from home. Luckily, my wife was by my side. Hannah had me admitted to the South Sinai Hospital, where I received excellent care. I want to thank all of the staff there for their kind help, and Dr. Shawket Gerges for successfully operating on me.