6 ms·
The Compositional Nature of Vim (2014)
- jasode 7y ago>What I’m trying to get at is that I never really took the time to learn how vim worked. I had no clue about the big picture. I didn’t know any concepts. [...] , really I was just getting by on ad-hoc memorization. [...] >Composition: The magic of vim is that it’s comprised of lots of small primitives that compose well together. Among these primitives are motions, operators, and text objects. This popular Stackoverflow answer also explains vim's concepts of "verb + noun": https://stackoverflow.com/a/1220118 https://stackoverflow.com/a/1220118 Also, a lot of beginners are perplexed why vi uses "hjkl" keys for cursor movement. It's because the 1976 ADM-3A terminal didn't have any dedicated arrow keys like the 1986 IBM PC 101-key layout: https://catonmat.net/why-vim-uses-hjkl-as-arrow-keys https://catonmat.net/why-vim-uses-hjkl-as-arrow-keys https://en.wikipedia.org/wiki/IBM_PC_keyboard#Keyboard_layouts https://en.wikipedia.org/wiki/IBM_PC_keyboard#Keyboard_layou... The "hjkl" overloaded with arrow movements is also related to why vi requires a "insert/append mode" that more modern text editors don't need. In vi, you're initially in "command mode" and you have to press 'i' or 'a' to insert or append text. In contrast, if you develop a new text editor after the introduction of keyboard hardware that has dedicated arrows/PgUp/PgDn/Home/End/Ins/Del/Fn1-Fn12, you no longer need to architect the editor software to have 2 special modes. Overloading the A-Z alphabet keys with non-text commands is what motivates having to switch between 2 modes. This leads to vi users repeatedly pressing the Esc key multiple times to really make sure they're no longer in text input mode. Instead of "<Esc>:wq<Enter>", the vi "wrong mode by accident" paranoia leads to "<Esc><Esc>:wq<Enter>". (EDIT ADD: the Esc key double-tap as reflexive muscle-memory may also be related to timeoutlen which many vi users are unaware of and don't change: https://stackoverflow.com/questions/15550100/exit-visual-mode-without-delay https://stackoverflow.com/questions/15550100/exit-visual-mod...)
- DennisP 7y agoSo for example, the Vim keyboard uses practically every key, for all sorts of commands. E.g. typing d) deletes to the end of the sentence, and to do it again I just type a period. I suppose you could remap most of the vim keys to function keys and so on and do the same thing, but it sure would be a pain to type. Pressing Esc multiple times might be an issue for terminal vim, but gvim uses different cursors to show what mode you're in.
- the_duke 7y ago> I suppose you could remap most of the vim keys to function keys Then you just end up with emacs. The modal editing is the defining characteristic of VIM for me, and why I use it everywhere. (directly or emulator plugins) Rebinding ESC to CAPSLOCK is essential for me though.
- DennisP 7y agoYep that's pretty much the point I was trying to make. Though I tend to imap jk :)
- linsomniac 7y agoWhat is this CAPSLOCK you refer to? #ergodox :-)
- chongli 7y agoYou had a really nice, informative comment about the history of vi and the weird keyboard of the ADM-3A terminal and then you had to take a cheap shot at vi users. Why? I've been using vi/vim/nvim for nearly two decades now and I only press escape (actually C-[, since I mapped caps to control) once each time I need to get out of insert mode. I don't have "wrong mode paranoia" because I can see at a glance what mode I'm in by the appearance of the cursor. When I finish inserting, the cursor moves one place to the left and highlights the last character I inserted. In vim it's even easier because the cursor changes appearance in insert mode.
- jasode 7y ago>you had to take a cheap shot at vi users. Why? You misinterpreted. I wasn't taking a cheap shot at vi users. When _I_ use vi, I press Esc multiple times. My behavior is common and this is apparently somewhat of an "in joke" among vi users. It's a behavior similar to pressing 'C' multiple times on calculators to really really clear out the entry. Pointing out that common behavior is not "taking a cheap shot at calculator users". Out of habit, I also press C multiple times on calculators and I don't know why I do that even though my brain's logic says it's redundant. https://www.reddit.com/r/Showerthoughts/comments/a7qeye/the_unspoken_rule_for_using_a_phones_calculator/ https://www.reddit.com/r/Showerthoughts/comments/a7qeye/the_... EDIT ADD: related HN thread about the ":wq" string accidentally being saved in source files because some vi users didn't realize they didn't escape text insert mode: https://news.ycombinator.com/item?id=7798529 https://news.ycombinator.com/item?id=7798529
- addicted 7y agoI’ve never heard of Esc Esc being an in joke amongst Vim users. And I rarely (never?) hit ESC twice, because it’s obvious when I just tapped ESC, and because of VIM’s speed I can immediately see when things changed. Is this a GVim/MacVim thing maybe? Is that slower? Or do all these people hitting ESC twice somehow have bad keyboards which don’t often transmit the ESC key signal? Also, the reason you hit C on calculators twice is because there is actually a reason to hit it in many calculators, and has no connection with Vim, and the difference between the 2 modes isn’t obvious. Hitting C once only clears the current result, but doesn’t clear the previous results. So if you type in 45+ the calculator after hitting C once (assuming you had 46 typed in), the calculator will add 45 to whatever you had originally. OTOH if you hit it twice, in many calculators it will also additionally clear out the previous results, so the 45+ only adds to 0.
- nesadi 7y agoYou no longer need to architect modal editors, but I'd say most people see enough benefit in it that it continues to persist, despite modern keyboards having arrow and function keys. Hell, I only just learned vim a few years ago, and it certainly wasn't because my keyboard lacked arrow keys (it didn't).
- blueboo 7y ago> Also, a lot of beginners are perplexed why vi uses "hjkl" keys for cursor movement. It's because the 1976 ADM-3A terminal didn't have any dedicated arrow keys like the 1986 IBM PC 101-key layout I dunno if accommodating a key layout out of use for decades is going to address the above perplexed reaction..
- jamesrcole 7y agoIt provides a keystroke-based language for working with textual information. That language embodies concepts that we think of the information and operations relating to it in terms of -- words, sentences, code blocks, etc, and deleting, changing, etc these. This allows us to directly translate our thoughts "I want to delete this sentence" into actions "das".
- mruts 7y agoI use Emacs and have been wanting to try spacemacs or evil because I suspect that modal editing is more efficient. Moreover my fingers hurt a lot and Emacs definately isn’t helping. The only thing preventing me from switching to evil (I would never switch to vim because it honestly just seems strictly inferior) is that I use Dvorak on a Kinesis keyboard. I’m not sure how well vim keybindings work on Dvorak, but I suspect not very well (atleast the hjkl part). Does anyone have experience with Dvorak and vim/evil? Is it acceptable?
- bloopernova 7y agoI'm a big fan of the composing commands in Spacemacs. http://ergoemacs.org/emacs/emacs_pinky.html http://ergoemacs.org/emacs/emacs_pinky.html for more about keeping your hands pain-free. Sorry, no experience with Dvorak and vim or spacemacs.
- linsomniac 7y agoI've heard a lot of speculation, from the vi camp, that Gosling and Stallman have RSI that emacs caused. Again, speculation. Google search for it, I can't find anything worth linking, all speculation. I do know people who have had wrist problems and found vi more comfortable. I know when I have to type control sequences I find it painful if I do too much. I'd say just try it and see if you find it more comfortable. Spend a couple weeks suffering through a bit less productivity and see where you are at. I did that a few years ago and am super happy with the results. In my case it was ditching some bad touch-typing habits and switching to a custom keyboard layout to optimize for my environment. As far as Dvorak, I've heard of people typing in Dvorak but doing command-mode in qwerty. That seems crazy to me, but would definitely work. I can't imaging switching layouts that frequently in my head, but I guess once you got used to it it'd be no big deal.
- dmortin 7y agoUsing emacs doesn't mean you have to use the default keys. I don't, because I find the defaults bad. I use the arrow keys and other bindings changed to my taste and my hands don't hurt. Emacs is only a bunch of defaults which you should adapt to your needs.