Live data from Hacker News

Vim Anti-Patterns

sanctum.geek.nz

1–10 of 249 posts

Re: Vim Anti-Patterns

#3
> "If you have to move more than a couple of lines, moving one line at a time by holding down j or k is inefficient."

This very point is actually why I moved from Vim to Emacs years ago. After mastering Vim, I realized that Vim strongly encourages you to think a little too much about exactly how to get there or do that thing in the fewest keystrokes, and that it's incompatible with muscle memory. Even years later, I still had to think too much about it. Whereas in Emacs I can just use basic character/word/line-based movements and let my muscle memory do its thing while I let my brain focus on the code itself instead of how to use the text editor.

Re: Vim Anti-Patterns

#4

I have a programmable keyboard, so I just map escape to be right above tab, where tilde usually is.

I use Karabiner + Seil to make my Macbook Pro's Caps Lock be Escape when hit by itself and Control when hit with another key. Unfortunately this doesn't work on Sierra yet so still on El Cap.

Re: Vim Anti-Patterns

#6
This is a great resource, but the article is pretty strict on the arrow keys. I would recommend `nnoremap`, over `noremap`, because it only disabled the arrow keys in Normal Mode.

The author's explains his rationale in the next section, it's to prevent users from living in Insert Mode. Fair enough. But, when making several relatively close edits, the ability to tap a few arrow keys in Insert Mode is far easier and less mentally demanding than any key combination that requires the user to bounce around different modes.

Re: Vim Anti-Patterns

#7
Useful stuff. I'd add typing J to move the next line to the end of the current line. A move I normally do by being on the next line and then type 0dwiBackspace.

Only just figured that one out by mistakingly having the capslock on when moving around.

Re: Vim Anti-Patterns

#8
This is good solid advice -- I have a problem with vim advice that golfs more unusual circumstances to save a keystroke or extensively remaps the keys. (Generally the only thing I remap is F1 to ESC, because I use laptops that place them inconveniently close together.) Devoting too many cognitive resources to text entry is also an anti-pattern!

Re: Vim Anti-Patterns

#9
post #3

> "If you have to move more than a couple of lines, moving one line at a time by holding down j or k is inefficient." This very point is actually why I moved from Vim to Emacs years ago. After mastering Vim, I realized that Vim strongly encourages you to think a little too much about exactly how to get there or do that thing in the fewest keystrokes, and that it's incompatible with muscle memory. Even years later, I…

As an Emacs user I want to plug ace-jump-mode to move around the viewable part of the buffer more efficiently than many of the commands mentioned in the OP's post.

1. look at character you want to go to 2. M-x ace-jump-mode (I have this bound to F9) 3. Hit key for the character you want to go to 4. All instances of them are rewritten in the buffer with a coloured character. 5. Hit the coloured character you are looking at.

The trick is to just look at where you want to go and touch type the rest. Even on very large monitors with dense data (I find this invaluable if I am going through an minimized HTML blob or a plaintext database dump) this can turn any point to be 3 keystrokes away. Cursor + search forward doesn't work if there is a lot of duplicate text around where you want to go, like a string of five .set* methods and you are trying to kill the third one

Re: Vim Anti-Patterns

#10
post #3

> "If you have to move more than a couple of lines, moving one line at a time by holding down j or k is inefficient." This very point is actually why I moved from Vim to Emacs years ago. After mastering Vim, I realized that Vim strongly encourages you to think a little too much about exactly how to get there or do that thing in the fewest keystrokes, and that it's incompatible with muscle memory. Even years later, I…

Just a question of practice, I found. I was a regular vim user in the past, and this was my criticism of in when first starting out - but after a while I found myself unthinkingly coming up with surprisingly complicated sequences of keypresses. It's possible to get very good at subconsciously sizing up editing operations.

These days I use emacs, and I pretty much always move the cursor using the mouse.

Post reply on HN