'(Vim Anti-Patterns)
Audience: intermediate
Some quote
Vim is such a rich editor. So rich that there are many ways to do things. And many ways some wrong ways, or at least inefficient ways.
Not understanding transactional editing
Arrow Keys
Default QWERTY keyboards
You may have heard some history about the QWERTY layout being suboptimal, but even worse than its layout is the IBM PC Model-M Keyboard Standard from 1986 we all got forced. Many programmers were lucky enough back then to use UNIX keyboards that had sensible Ctrl, Esc, and others. But today we all use laptops with horrible layouts. There are a few egregious issues with the
If you have not modified your mappings, you are not meeting your potential.
Enter key
You may kill you wrist. Look how it pivots to reach your pinky. Enter
is in a
terrible position.
A Better Way
Surrounding things manually
Put quotes around a word.
The quick brown fox... ^
Bi"<esc>ea"
That’s 7 keystrokes, 10 if you count the Shift`s. What a pain. With the
[Surround] plugin you can just type `csw"
.
x
Too easy to make a habit out of xxx
.
Excessive hjkl
Leaving the window in INSERT mode
Staying in insert mode
Need to Esc in order to save transaction.
Ignoring bold, italic, and 256 colors
Repeating
A Better Way
Use Ctrl-J
.
Not learning about “objects”
The first thing most of us were taught about Vim was movement.
Vim knows about objects: sentences, words, quotes, paragraphs, and more. You can even define your own.
gqap daw dis ysiw
Using the mouse
Not using built-in help
Not leveraging the powerful “repeat”
Adopting a distribution you don’t understand
Relying too much on visual mode
Save, Change window, refresh browser/suite, back to window, edit
Use write hooks.