>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.
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:
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>".
So 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.
You 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.
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.
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
I’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.
I learned vi (not vim) on old DEC and IBM AIX machines via Telnet (not local GUI). With those more primitive console emulators, the cursor change for different modes wasn't obvious.
>Or do all these people hitting ESC twice somehow have bad keyboards which don’t often transmit the ESC key signal?
For whatever reason (e.g. possibly unawareness of timeoutlen delay causing Esc to behave in unexpected ways), many vi users end up redundantly pressing Esc twice.
>Hitting C once only clears the current result, but doesn’t clear the previous results.
I thought the newer calculators with dedicated "C" (clear) and "CE" (clear entry) didn't require pressing "C" multiple times. (I just tested this on a Texas Instruments desk calculator with dedicated C & CE buttons and it only requires pressing C once to clear out everything. (But I still press C multiple times out of habit.))
Also newer calculators have a distinction. But I’ve definitely used older ones where both keys were on the same button (separated by a slash?) but I know I habitually press C twice and it’s likely because the calculator I used most growing up needed you to press C twice for CE.
I have a wrong mode paranoia when I sometimes hit the shift lock key and end up triggering something and find myself in a new tab. Then I close the tab and carefully hit escape many times before undoing whatever was done. It's not my default mode but when I misfire the missile instead of hitting the brakes it's nice to throw some escapes over the fire before getting it under control.
I press Esc multiple times. I don’t need to anymore, I know. But when I was first learned Vi/Vim 25 years ago I sometimes did and it stuck. I also “:w” multiple times for the same reason. Better safe than sorry I guess.
I also use “hjkl” for navigation instead of the arrow keys by force of habit because back when I was learning Vi/Vim the arrow keys would sometimes result in odd behavior depending on what system I was in. But “hjkl” always works. Also, modern Mac keyboards...
> 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..
You 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).
It 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".
I 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?
I'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.
Using 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.
19 comments
[ 2.2 ms ] story [ 61.9 ms ] thread>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
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://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-mod...)
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.
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.
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.
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_...
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
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.
I learned vi (not vim) on old DEC and IBM AIX machines via Telnet (not local GUI). With those more primitive console emulators, the cursor change for different modes wasn't obvious.
>Or do all these people hitting ESC twice somehow have bad keyboards which don’t often transmit the ESC key signal?
The Esc-double-tap was a very common way to make sure you're not in text insert mode: https://www.google.com/search?q=vi+"press+esc+twice"+command
For whatever reason (e.g. possibly unawareness of timeoutlen delay causing Esc to behave in unexpected ways), many vi users end up redundantly pressing Esc twice.
>Hitting C once only clears the current result, but doesn’t clear the previous results.
I thought the newer calculators with dedicated "C" (clear) and "CE" (clear entry) didn't require pressing "C" multiple times. (I just tested this on a Texas Instruments desk calculator with dedicated C & CE buttons and it only requires pressing C once to clear out everything. (But I still press C multiple times out of habit.))
Also newer calculators have a distinction. But I’ve definitely used older ones where both keys were on the same button (separated by a slash?) but I know I habitually press C twice and it’s likely because the calculator I used most growing up needed you to press C twice for CE.
I also use “hjkl” for navigation instead of the arrow keys by force of habit because back when I was learning Vi/Vim the arrow keys would sometimes result in odd behavior depending on what system I was in. But “hjkl” always works. Also, modern Mac keyboards...
I dunno if accommodating a key layout out of use for decades is going to address the above perplexed reaction..
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?
http://ergoemacs.org/emacs/emacs_pinky.html for more about keeping your hands pain-free.
Sorry, no experience with Dvorak and vim or spacemacs.
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.
Emacs is only a bunch of defaults which you should adapt to your needs.