Practical Vim: Edit Text at the Speed of Thought

Practical Vim: Edit Text at the Speed of Thought

Language: English

Pages: 320

ISBN: 1680501275

Format: PDF / Kindle (mobi) / ePub


Vim is a fast and efficient text editor that will make you a faster and more efficient developer. It's available on almost every OS, and if you master the techniques in this book, you'll never need another text editor. In more than 120 Vim tips, you'll quickly learn the editor's core functionality and tackle your trickiest editing and writing tasks. This beloved bestseller has been revised and updated to Vim 7.4 and includes three brand-new tips and five fully revised tips.

A highly configurable, cross-platform text editor, Vim is a serious tool for programmers, web developers, and sysadmins who want to raise their game. No other text editor comes close to Vim for speed and efficiency; it runs on almost every system imaginable and supports most coding and markup languages.

Learn how to edit text the "Vim way": complete a series of repetitive changes with The Dot Formula using one keystroke to strike the target, followed by one keystroke to execute the change. Automate complex tasks by recording your keystrokes as a macro. Discover the "very magic" switch that makes Vim's regular expression syntax more like Perl's. Build complex patterns by iterating on your search history. Search inside multiple files, then run Vim's substitute command on the result set for a project-wide search and replace. All without installing a single plugin! Three new tips explain how to run multiple ex commands as a batch, autocomplete sequences of words, and operate on a complete search match.

Practical Vim, Second Edition will show you new ways to work with Vim 7.4 more efficiently, whether you're a beginner or an intermediate Vim user. All this, without having to touch the mouse.

What You Need:

Vim version 7.4

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Look up 'complete' ​ to find out what each of the flags does. Tip 114 Autocomplete Words from the Dictionary Vim’s dictionary autocompletion builds a list of suggestions from a word list. We can configure Vim so that dictionary autocompletion uses the same word list as the built-in spell checker. Sometimes we might want to use autocompletion on a word that isn’t present in any of our open buffers, included files, or tags. In that case, we can always resort to looking it up in the

repetition. In order to exploit this, we have to be mindful of how we compose our changes. In Vim, we always have more than one way of doing something. In evaluating which way is best, the most obvious metric is efficiency: which technique requires the fewest keystrokes (a.k.a. VimGolf[3]). But how should we pick a winner in the event of a tie? Suppose that our cursor is positioned on the “h” at the end of this line of text, and we want to delete the word “nigh.” normal_mode/the_end.txt

go through these techniques again. This time, we’ll finish by invoking the dot command and see what happens. I urge you to try these out for yourself. The backward deletion technique involves two operations: db deletes to the start of the word and then x deletes a single character. If we invoke the dot command, it repeats the single character deletion (. == x). That’s not what I would call a big win. The forward deletion technique also involves two steps. This time, b is just a plain motion,

this has some resemblance to the Dot Formula. It involves one keystroke to move (j) and two to act (@a). Not bad, but there’s room for improvement. We have a couple of techniques at our disposal for executing a macro multiple times. The setup differs slightly for each technique, but more importantly, they react differently on encountering an error. I’ll explain the differences by way of a comparison with Christmas tree lights. If you buy a cheap set of party lights, the chances are that they

field of the substitute command blank. It’s tempting to think that leaving the replacement field blank would also reuse the string from the previous substitute command, but this isn’t the case. Instead, a blank replacement field instructs the substitute command to replace each match with an empty string. In other words, it deletes each match. Pass by Value We can insert the contents of a register by typing {register}. Suppose that we have yanked some text and want to paste it into the

Download sample

Download