16 ms·
Fun fact about vim: When vi was originally designed the most popular keyboard was ADM-3A and later IBM XT https://en.wikipedia.org/wiki/IBM_PC_keyboard#/media/
by a-b 10y ago
Fun fact about vim:
When vi was originally designed the most popular keyboard was ADM-3A and later IBM XT https://en.wikipedia.org/wiki/IBM_PC_keyboard#/media/File:IBM_Model_F_XT.png https://en.wikipedia.org/wiki/IBM_PC_keyboard#/media/File:IB... The layout of this keyboard has Control on the place where modern keyboards have a CapsLock key. Naturally that's why vi and vim was meant to use CTRL-[ to exit to the normal mode.
25 years later Apple introduced ToughBar and made ESC key virtual. As result remapped CapsLock-[ make sense again ;)
edit: Add ADM-3A keyboard
- cseelus 10y agoActually I have remapped Caps-Lock to ESC and when pressed longer than a few ms to Ctrl system wide for years, with the Karabiner app. I read about that neat productivity boost that also reduces the strain on your left hand a lot in a blogpost which "sold" this idea as "this is how VIM was intended to work" and I really love it. Useful even for normal terminal combos like Ctrl+C. Only downside is, once you get used to it, you just can't go back ;-)
- tnorthcutt 10y agoSadly on macOS Sierra, you have to use Karabiner-Elements, which doesn't (yet, I hope) include support for long-press=ctrl.
- The_Hoff 10y agoIf you're fine giving up caps lock, Sierra makes it easy to remap caps lock to esc in Systems Preferences (it even disables the little green light on the key)
- toxik 10y agoWow, that's news to me! How I've waited for Apple to do this. Karabiner-Elements does some shady stuff with the kernel and in my experience makes the machine a lot less reliable.
- ikurei 10y agoSadly, that isn't as powerful as what our comment-ancestors do with Karabiner. Such an accessible and prominent key as Caps Lock is, IMHO, wasted if only used for ESC; using it both for Control when in combinations and ESC when alone makes the most sense. I use Caps Lock for Cmd or Ctrl, depending on which keyboard I'm using, and <Leader><Leader> for Escape on Vim. I don't know where I got this idea from, but I also use <Leader>w to exit to normal mode and save. It's so ingrained in me, that when I use other editors very often I have "Unexpected token" errors because of a ",w" in the middle of the code.
- yankcrime 10y agoFWIW you can also use Keyboard Maestro to solve this problem.
- innocentoldguy 10y agoI use Keyboard Maestro for exactly this purpose. For the most part, it is great. However, it does just stop working every now and then, at least for me, which is mildly irritating.
- drewm1980 10y agoI am surprised to learn that the set of people who use vim and the set of people who have patience to "long-press" intersects!
- steeef 10y agoThere is a pull request to implement this feature: https://github.com/tekezo/Karabiner-Elements/pull/247 https://github.com/tekezo/Karabiner-Elements/pull/247 I haven't tried it myself. Honestly it's one of the things keeping me from upgrading to Sierra. Need to test it out first.
- Something1234 10y agoAny way to do the remap with Gnome on Linux?
- c94o8e 10y agognome-tweak-tool --> Typing --> Caps lock key behavior --> (near the bottom) select the swap option
- falcolas 10y ago> once you get used to it, you just can't go back So true. So many capital letters typed and deleted.
- kps 10y ago> when vi was originally produced most popular keyboard was IBM XT. Probably not, since the IBM XT was five years in the future. The canonical vi keyboard is the ADM-3A. http://terminals-wiki.org/wiki/index.php/File:Lear_Siegler_ADM-3A-2.jpg http://terminals-wiki.org/wiki/index.php/File:Lear_Siegler_A... Escape is almost as accessible as Control. The ADM-3A also explains why shells use ‘~’ to represent the home directory.
- a-b 10y agoYou're right, thanks for your correction. My main point was a location of the Control key. I guess with IBM XT keyboard CTRL-[ become a most reasonable option https://en.wikipedia.org/wiki/IBM_PC_keyboard#/media/File:IBM_Model_F_XT.png https://en.wikipedia.org/wiki/IBM_PC_keyboard#/media/File:IB...
- ntumlin 10y agoI was curious about some keys I hadn't seen before, so for anyone curious, here's the purpose of the "rub" and "here is" keys (from the ADM-3A operators manual[0] page 3-7 and 3-8): RUB. When the RUB (rubout) key is typed while holding down the SHIFT key, a non-displayable rubout code (ASCII DEL) is transmitted to the computer. The cursor is not advanced and the character code stored in display memory is not overwritten. RUB is normally used to tell the computer that a previous character should be deleted. HERE IS. If the Answer Back option is installed, typing this key transmits an identification message (stored in a special ADM-3A memory) that identifies the terminal and alerts the host computer that a message is to follow. If no Answer Back option is installed, the key has no function. [0] http://www.classiccmp.org/dunfield/altair/d/adm3a.pdf http://www.classiccmp.org/dunfield/altair/d/adm3a.pdf
- kps 10y agoFor the reason DEL is shifted ‘_’, see your friendly neighbourhood ASCII table, and/or one of the recent HN threads¹. The ADM-3A² is a good example of a bit-paired keyboard³. ¹ https://news.ycombinator.com/item?id=13539552 https://news.ycombinator.com/item?id=13539552 ² https://en.wikipedia.org/wiki/ADM-3A https://en.wikipedia.org/wiki/ADM-3A ³ https://en.wikipedia.org/wiki/Bit-paired_keyboard https://en.wikipedia.org/wiki/Bit-paired_keyboard
- lytedev 10y agoWhy not use "jk" or "jj"?
- lunchladydoris 10y agoDiscovering this really changed Vim for me. That and remapping j and k to move over visual lines instead of logical lines.
- Rusky 10y agoPersonally that slows down normal usage of j too much for me.
- ngokevin 10y agoIt doesn't have an effect if you type a single `j`.
- jcl 10y agoThese can be convenient if you are only entering text manually. But remapping regular -- albeit rare -- text sequences can have unexpected results when pasting copied content into insert mode in a terminal window. I've been bitten by this a couple times when pasting base64-encoded data.
- nick_g 10y agoThis has caught me as well, but it can be avoided by using `:set paste!` to toggle paste mode before pasting. This isn't something I need to worry about often enough but you can map that command if pasting external content is something you do often.
- marklgr 10y agoMost terminals support bracketed paste, and vim can automatically toggle pastemode based on the special sequences. Eg. https://github.com/ConradIrwin/vim-bracketed-paste https://github.com/ConradIrwin/vim-bracketed-paste
- MichaelGG 10y agoWhy does a combo with two keys on opposite sides of the keyboard make sense? Surely something that can be hit with one hand is easier? I'll have to try this for a week.
- highwind 10y agoI personally find using two hands for pressing key combinations more comfortable than holding a modifier key with a pinky and reaching for the other key.
- nilved 10y agoRight, but wouldn't you prefer using one key?
- bryogenic 10y agoBecause Ctrl+[ = ESC in ascii https://garbagecollected.org/2017/01/31/four-column-ascii/ https://garbagecollected.org/2017/01/31/four-column-ascii/
- freehunter 10y agoBack then there was no mouse so both of your hands were on the keyboard full time. If you have two hands, it's a shame not to use them both.
- javitury 10y agoFor me the best way to have an accessible ESC key is just to use Alt-h, Alt-j, or just pressing Alt with any normal mode key. It will work on any vim installation out of the box, it is easily accessible and doesn't require remapping.
- groovy2shoes 10y agoAs long as your terminal is configured to send the Meta modifier as an ESC prefix rather than a shift bit, and as long as your Alt key serves as Meta.
- cassowary 10y agoI've set my capslock to be escape and my alt to be control. I don't know where my alt is, but I've never really used it. (I think the only usecase for alt is Alt-Tab to switch windows, but that always feels epically unpredictable to me. What's going to happen? ... I prefer just clicking on the window I want).
- bryogenic 10y agoAlso worth noting: Ctrl+[ = ESC in ASCII, which is where the keyboard shortcut comes from. https://garbagecollected.org/2017/01/31/four-column-ascii/ https://garbagecollected.org/2017/01/31/four-column-ascii/
- inlineint 10y agoAnd it is processed not by Vim itself, but by the terminal emulator that sends Esc character to Vim. So the shortcut Ctrl+[ was not invented by vi author, but is a consequence of using Esc to exit from the edit mode.
- pvg 10y agoThat's fun but not a 'fact'. The ADM-3A keyboard had an 'ESC' key and it was positioned right where the tab key is typically today. Very easy to hit. Here's a write up with nice pictures. http://www.catonmat.net/blog/why-vim-uses-hjkl-as-arrow-keys/ http://www.catonmat.net/blog/why-vim-uses-hjkl-as-arrow-keys...
- pault 10y agoMy employer bought me a macbook with the touchbar and I've had to retrain my muscle memory to use C-[. It took a couple of weeks for it to feel natural but it wasn't nearly as bad as I expected it to be. I still haven't found a killer app for the touchbar, though.
- bartvk 10y agoMe neither, but the TouchID is terrific.
- enthdegree 10y agoAn aside, PC XT keyboards can still be found on ebay for ~$40 and are great to use after being adapted and remapped with a microcontroller.