Live data from Hacker News

Vim Anti-Patterns

sanctum.geek.nz

201–210 of 249 posts

Re: Vim Anti-Patterns

#202
post #186

Earlier quoted context omitted.

Plug for Karabiner on OS X, which lets you use capslock as a control if you press it with another key, and escape if its released on its own. It has ruined me for other computers that don't have this set up. There's also a way to do it under Linux, but I can't remember what the package is that lets you do that.

You're thinking about xcape: https://github.com/alols/xcape . FYI, Karabiner is incompatible with MacOS Sierra. There's a project (Karabiner-Elements) to replace its (and Seil's) functionality, but I don't believe it has feature parity yet: https://github.com/tekezo/Karabiner-Elements

[deleted]

Re: Vim Anti-Patterns

#203
post #26

These are all good tips but most of the anti-patterns seem to skew towards beginners ( e.g. don't use the arrow keys, don't navigate in insert mode). One that I think is more common among intermediate, and even advanced, users is the misuse of tabs, windows, and buffers. A lot of people have a tendency to think of each tab as corresponding to a single open file. This is very understandable because it closely matches…

Well, I've been using vi and it's brethren since about 2002 and I've pretty much always used the arrow keys; after some point it becomes muscle memory... I never really understood what the problem with this was; I rarely actually use them (esc|capslock /str,ctrl+f|b etc) is usually how I move around and if I'm wanting to move a few chars my little finger is not moving very far (at least, on apple keyboards)... Is thi…

> Do you see any big advantage of using a lot of buffers/tabs/splits over running multiple vims inside tmux?

One advantage would be the ability to use vim registers to copy text from one buffer to another instead of having to go through tmux or screen. Another would be word or line completion in a given buffer using contents in another buffer. In general, by running multiple vim instances instead of a single vim instance, you lose the opportunity to leverage vim to manage multiple buffers by using information in a given buffer.

Re: Vim Anti-Patterns

#204
post #34

> It’s always useful to jump back to where you were, as well, which is easily enough done with two backticks, or gi to go to the last place you inserted text. I And here I was undoing and redoing the entire time.

Hah, me too. Also yank-then-undo instead of finding out how to actually select and copy text.

Meh whatever, it works, and the amount of time I spend in vim these days is so minimal that I doubt it's worth it to retrain.

Re: Vim Anti-Patterns

#205
post #103

"Hitting Escape is usually unnecessary; Ctrl+[ is a lot closer, and more comfortable." I agree with a lot of the things in this article, but wow, I could not possibly disagree with this quote more. Ctrl+[ is WAY more uncomfortable than using the Escape key. Granted, I have many years of vim usage that have made hitting Escape a habit, and that probably plays a big part in it, but Ctrl+[ is downright painful for me (a…

> I could not possibly disagree with this quote more. Ctrl+[ is WAY more uncomfortable than using the Escape key.

Did you try it with one hand or two. I do it by using my left pinky on the ctrl key and my right pinky on the [ key. In general, I've always tried to stick with the touch typing convention where you use the modifier key on the opposite side of the keyboard relative to the key you press.

For example, I will always press the left shift key for capitalizing I and the right shift key to capitalize A (and similarly with the alt or ctrl keys). It's more ergonomic, IMO (and also the reason I dislike keyboards that are missing modifier keys on one side of the keyboard).

Re: Vim Anti-Patterns

#206

While these tips are good per se, in retrospect I don't think it's that a good idea to tie your muscle memory that much to a single piece of software. I'd say enjoy the cursor keys. Moving around in insert mode is ok too.

Alternatively, you could just run :set mouse=a and then use your mouse to do things like scrolling, moving the cursor and selecting text. It's definitely a bit faster than using the arrow keys, but not as fast as knowing the most common vim normal mode keybindings.

Re: Vim Anti-Patterns

#207
While it's unarguably fun, I can't believe the effort required to become actually good at vim (as opposed to just using a few of the easier features) will ever pay itself off. (These days, at least - if you spend your days editing code in a terminal over a dialup connection, then it's absolutely worth it!)

Maybe there are scenarios where the busywork of text editing really is on your critical path, but even as a fluent coder who uses some verbose languages at times (my current project is C++ and IEC Structured Text, does it get any more blabby?) I still spend far more of my time looking at, and thinking about, code than I do actually typing. Any extraneous cognitive load just takes focus away from what I'm actually meant to be doing.

Re: Vim Anti-Patterns

#208
post #207

While it's unarguably fun, I can't believe the effort required to become actually good at vim (as opposed to just using a few of the easier features) will ever pay itself off. (These days, at least - if you spend your days editing code in a terminal over a dialup connection, then it's absolutely worth it!) Maybe there are scenarios where the busywork of text editing really is on your critical path, but even as a flue…

Did you take the time to learn vim? Just start using it. With only a small subset of commands you can be pretty damn efficient. The fact that you can compose actions means that you don't need to remember every command - you can just create them yourself. After a very short while you will "get" it. You can say to yourself "I want to change the next three words" and immediately do it by pressing "c3w". Or you can move around with your mouse. The former is much faster.

BTW, I rarely use escape. I am using Spacemacs with evil-mode, and the default "fd" is perfect for me. It's much faster than using ESC.

Re: Vim Anti-Patterns

#209

Earlier quoted context omitted.

I decided one year that I would force myself (a vi die-hard) to use emacs for everything for an entire year, to see if I ever got used to it. One thing that never stopped driving me crazy was that there's no efficient way to duplicate a line like yyp in vim. The closest I could ever get in emacs was ctrl+k k ctrl+y ctrl+y (that is, delete the line and then paste it back twice). Looking online for a solution leads me…

...Which is actually quite simple. Here's my function for doing that that I wrote just now: (defun duplicate-line (interactive) (kill-whole-line) (yank) (yank)) Five lines, and it took me all of ten minutes to write, including looking up the names of all the functions. Of course, there's probably a better way to do this, but I don't know what it is. Now all you have to do is bind it to a key. Or, of course, you could…

I have mine set up like this:

https://gist.github.com/asummers/7784d40b1bc53ee309777274e9d...

That way I can hit M-w when I don't have a region and get the copy behavior for the whole line.

Re: Vim Anti-Patterns

#210

I started off using Emacs a lot (like tons and tons of Emacs with tons and tons of custom modes, functions, and craziness - network pong anybody?). For almost a summer, my xinitrc at the school labs literally opeed up a full screen Emacs; it was my window manager too. The simplicity of vim (and pretty colors) drew me in. Plus as I learned more sed/ed, I understood vi more. That, and a slow connection from off campus…

> I wonder if you could make a vim code golf puzzle set

http://vimgolf.com

Post reply on HN