Hacker News new | ask | show | jobs
by tetraodonpuffer 3394 days ago
When I read articles about vi/vim being great for coders I always wonder how you deal with having to use the same part of your brain for writing the code you are writing and to "code vim commands"

I mean, I understand it's attractive to a programmer's mind to be able to do fancy 'replace the next 3 words with x' and so on, and compose them in vim's language, but if I am deep in an algorithm the last thing I want is to have to context switch to "programming my editor"

When doing editing tasks in a more visual as opposed to programmatical way, it feels more that my "coding brain" is free to continue working on the algorithm at hand while some other part of my brain deals with the moving of text around.

Keeping the right cursor key pressed for 1 second is a lot slower than doing some fancy move to the X word in the line, but if engaging my brain to create the composite "move to the X word" command takes me out of the "flow state" I am in, it is way way way more expensive in the long run. In the end what you want is to be the most productive, and the most productive could mean that you are using the editor less efficiently because the more efficient parts of your brain are busy doing something else.

Not sure, maybe somebody that started with vim as their first editor does not have this context switching issue, I personally started with emacs and remained with it and I have my emacs config full of hyper / super / meta / alt / control / shift shortcuts and tons of cool packages, but while I am deep in coding flow state I still use the cursor keys with minimal package help (outside of multiple-cursors and macros sometimes) to avoid getting distracted.

4 comments

I am actively using a vim-like control scheme for almost any text I write for about 15 months now. I certainly am not the most proficient in it (in fact, I suspect I could do much better if I weren't "confined" to VS and VSVIM at work - I use Spacemacs privately), but I have enough "training" to make the basic moves I need unconciously. If you come from more limited IDEs or text editors this alone is already well worth it. And at the moment when you understand the basic gist of macros on top of that, it basically becomes a superweapon.

I'm sure there's something to get out of being an "expert Vim user", but even if you're starting out, there's already much to be gained from the simple routines. I find the notion of a "Vim Kata" very compelling as a metaphor, since it's really the repetition that teaches those "reflexes" at first.

I don't know how much an avid Emacs user could get out of it though. I guess that comes down to personal preferences. I couldn't get myself to memorize all the weird key combinations for example, but I quite like Spacemacs' mnemonics system.

> I always wonder how you deal with having to use the same part of your brain for writing the code you are writing and to "code vim commands"

I think the transformations you think about map very nicely to vim commands. If you want to move some code around for instance, the action you want in the brain is "delete line" and the vim mapping is "dd". So I'm never thinking about vim commands, I just have an internal mapping for the change I want to the command to do it.

This is where I find the productivity comes from, with a normal editor you go thought->action, thought->action, etc and I find if action is to long it can break the thought part.

This is a great point that I wish I wrote about.

I think this is actually the source of the "steep learning curve" problem. Once you've used it enough, it is an almost orthogonal part of your brain that does thats the VIM command-ing. It becomes more like, "to walk, put one foot in front of the other." You don't actually process that thought when walking.

But, until that point, it absolutely IS the same part of your brain. Until that point, there IS a PAINFUL contention between work brain and editor brain.

I'm not a super advanced Vim user (I mostly use hjklbw with numeric prefixes to get around) but it's all muscle memory, and I don't ever feel like I'm context switching.