8 ms·
Two things that helped me more than anything with "learning" vim and or ever wanting to use it: 1. Remap your "capslock" key to "escape." Vi was written using
by rubyn00bie 6y ago
Two things that helped me more than anything with "learning" vim and or ever wanting to use it:
1. Remap your "capslock" key to "escape." Vi was written using an ADM-3A terminal and its keyboard, which you can see here: https://catonmat.net/why-vim-uses-hjkl-as-arrow-keys https://catonmat.net/why-vim-uses-hjkl-as-arrow-keys has the escape-key in a sane place. On modern keyboards, if you can, remap "capslock" to "escape" when pressed alone, and "ctrl" when pressed with another key.
2. Make your leader key something easy like the comma character "," E.g. to make a horizontal split, I press (not including quotation marks) ",h" or ",v" to make a vertical one.
Once I did those two things it all made so much more sense... It's also great because most editors these days support vim bindings, so even if you don't want to use vim you can still benefit from its really-awsome-once-you-figure-it-out UX.
- johnfn 6y agoI just use ctrl-c instead of esc. Infinitely more accessible than esc or even ctrl bracket - it mystifies me why it’s not more commonly known. Only problem is that it quits you out of macros, so you need to use esc then, but that’s easy to remember and I use ctrl-c probably 4 orders of magnitude more than I use macros. (In fact, multi cursor mode in vscode vim obsoletes them for me entirely!)
- Lio 6y agoIt’s not that ctrl-c isn’t widely known it’s that Escape and ctrl-c are not equivalent in Vim. Ctrl-c breaks all kinds of things including repeats, so ctrl-[ is usually a better choice.
- atweiden 6y agoDie hard vimeleon here. IMHO chording the 'j' and 'k' keys simultaneously [1] is a severely underutilized solution for escape. Try it. You'll love it. If you're going to rebind capslock to something — and this is particularly true if you're on macOS — rebind it to backspace. Capslock escape isn't useful outside of Vim. Backspace is useful everywhere, including inside Vim. [1] https://github.com/kana/vim-arpeggio https://github.com/kana/vim-arpeggio
- pessimizer 6y ago> If you're going to rebind capslock to something — and this is particularly true if you're on macOS — rebind it to backspace. No, rebind it to Compose. Makes life a lot easier. https://en.wikipedia.org/wiki/Compose_key https://en.wikipedia.org/wiki/Compose_key
- atweiden 6y agoThat's interesting. I'm a bit spoiled by primarily using Vim to write code and prosé in American English. Vim's digraph feature (Ctrl-K by default) has handled unicode char input nicely enough for me, but I wonder if the compose key could be of use when writing text in Japanese for example.
- pessimizer 6y agoI actually meant to do it systemwide, for when you're writing or googling things not in English, or when you want to write a fancy ⅝. The day I have to start putting diacritics into computer code is the day I quit programming:) I think it's no good for Japanese, but I know very little about Japanese input. Romanji is still Japanese, right?
- owl57 6y agoNow that's an idea. Haskellers routinely use x' as a variable name, but ẋ and x̃ are also valid ones!
- fictorial 6y agoI use option-e e to insert é, option-n n to insert ñ, etc. I noticed this while pressing option in the Keyboard Viewer.
- Lio 6y agoThe problem with your jk solution is that it doesn’t work in other Vi-like interfaces such as those provided by readline or shells. Also ctrl-h is backspace so mapping caps to ctrl gives you a convenient escape and backspace shortcut. (It also gives you a heap more terminal shortcuts but that’s another story).
- moonchild 6y ago> Remap your "capslock" key to "escape." I hear this recommendation a lot. You can do that, but much better is to get a keyboard with a proper thumb cluster like a kinesis[1], maltron[2], dactyl[3], ... Much better to put such a common key on the thumb than stress out a pinky. I have a kinesis, and have esc mapped to the 'end' key there; similar positioning is possible on other keyboards. The keyboards I linked are also much more ergonomic than most flat keyboards—important, if you rely on your hands and wrists for your livelihood. Bit expensive, but well worth it. 1. https://kinesis-ergo.com/shop/advantage2/ https://kinesis-ergo.com/shop/advantage2/ 2. https://www.maltron.com/ https://www.maltron.com/ 3. https://github.com/adereth/dactyl-keyboard https://github.com/adereth/dactyl-keyboard
- asciimov 6y agoSeveral years ago I finally developed RSI. It took nearly a year of different setups and exercises to figure out what would work. The cause of RSI for me was a well known ergo keyboard. I had been using it for nearly a year before the pain/numbness started in my hands. I went back to standard slab keyboards, and every time I use a ergo keyboard the issues flare up again. So, while I like the style of those keyboards, I can't justify spending that much if I am likely to develop RSI again. --- I'm one of those weirdo's that has remapped caps to Lctrl/esc, tab to hyper/tab, \| to alt/\|, return to Rctl/enter. It's comfortable. (Ralt is now Compose/Dead Greek and Rctrl is Caps Lock) I would love more buttons to the left of the keyboard. I currently use a 10-keyless but would love a cluster of 10-15 keys to the left of my left hand. and possibly 6 keys under the thumb area. And a real dedicated hyper key. Maybe another row of F-Keys too...
- loxs 6y agoFor me it was enough to just remap my right Alt to Ctrl. No need for expensive hardware which I can't bring with me everywhere. The ThinkPad keyboard is good enough.
- marcrosoft 6y agoRemap esc to ‘kj‘ instead. It’s faster to type than ‘jj’ it’s on the home row and doesn’t require a custom binding. The sequence kj is rarely used in English or coding.
- Nimelrian 6y agoWhat a hackjob that is.
- qwerty456127 6y ago> Remap your "capslock" key to "escape." Isn't it possible to configure vim to just use the actual CapsLock status for the mode switch?
- Lio 6y agoOn remapping caps: ctrl-[ is escape in terminals by default. It’s often easier to map caps to ctrl than escape when pressed and ctrl when held. Most OSs support that without extra software. Even in Vim it’s still very useful to have a convenient ctrl key. A lot of useful features make use of Ctrl in Vim. On remapping leader: Remapping to spacebar means your thumbs are dedicated to that operation. That’s more balanced left-right for touch typing. Also you get to keep the default behaviour.
- aydoo 6y agoRegarding 2, I think using 'space' as leader will be the most easy one to get into. You don't lose any meaningful functionality and space is (ideally) operated with your thumb, which means you can bind any key combination without awkward hand movements.
- in9 6y agoI see the value of remaping the esc key to cpaslock, but my hands are quite big and I can reach esc on most keyboards quite effortlessly.
- haolez 6y agoAbout 1., you can simply use ctrl-] as an alternative Escape command.
- JoshMcguigan 6y agoWhen I was first learning Vim I remapped caps lock to escape, and it was a huge improvement. But as I became more comfortable in Vim I realized I was using the control key a lot. I've since remapped caps lock to control, and use ctrl-[ as escape (this is default behavior). I find having an easily accesible control key is very useful, even outside Vim. You can see in your link that it is actually the control key that used to be in the position we now put the caps lock key. It does seem like remapping caps lock to escape when pressed alone and control when pressed with another key would be nice, but that wasn't an option for me (on wayland) as far as I know. I bring this up only because there was a week or two transition period when I made this change, and I probably would have been better off if I had mapped caps lock to control from the start.
- deleted 6y ago[deleted]
- wyclif 6y agoThis is what I do on both Linux and macOS. I like remapping Caps Lock to Ctrl/Command because it's the UNIX-style key layout I'm used to on the old IBM Model M keyboards, and my left and right pinky fingers are used to the Ctrl-[ combination, it's burned into muscle memory.
- loxs 6y agoI remap my right Alt to Ctrl. The best thing I have ever done with regards to ergonomics. It works wonders in all softwares, not only vim. It's much more convenient to press with the thumb than CapsLock is with the pinkie.
- cbcoutinho 6y agoI recently learned this trick since getting a new MacBook pro with the touch bar esc key. I couldn't stand the lack of travel and didn't want to remap keys, now I use the ctrl-[ combo on all keyboards out of habit
- QuelqueChose 6y agoRelevant to the other conversations going on in this thread, how simple is it to re-map that ctrl-[ to work globally? I'm assuming I'd have to install something for this. I am also using a Mac and use the caps-lock-as-escape to, say, close my spotlight search bar after activating it using the command+space shortcut.
- ectoplasmaboiii 6y agoI'm personally a fan of remapping jk or jj to esc, there barely any instances in the english language where you would use those two letters together, and it means you can leave insert mode whilst barely moving your hands :D
- flukus 6y agoI use zz, it's similarly rare and compliments ZZ (save and quit) well.
- dri_ft 6y agoBut how are you gonna solve fizzbuzz?
- njharman 6y agoI like kk.
- Tcepsa 6y agoThe first thing I put in my .vimrc on any system: inoremap jk <ESC> I learned it through Spacemacs and it's one of the things that really made modal editing work for me, so I was thrilled to discover that Vim itself also supports it. (I'd tried to learn Vim before, but always having to jump over to the Escape key was a huge downer for me, and coming from Emacs I'd already mapped my CapsLock to Ctrl--though the idea of having it be Esc if pressed by itself is intriguing and I need to look into it more!)
- I_complete_me 6y agoI use jk too. Happy with it. My .vimrc has this: set <esc>=jk I wonder what the difference is.
- alpaca128 6y agoMy issue with this is that it causes a delay with every single j that is entered. Only a visual delay that freezes the cursor and then lets it jump by two characters, but irritating for me regardless. Otherwise it's very practical though.
- chongli 6y agoMake your leader key something easy like the comma character "," I would do this but I use the comma and semicolon keys all the time. I find them so useful. Gosh vim is weird. Everyone uses it differently!
- leephillips 6y agoI guess you mean you use them to insert ,s and ;s. But the leader key would not be for insert mode, so you can choose anything convenient.
- chongli 6y agoNo, I use them with the f and F keys. They repeat the previous character search in forward and backward directions.
- atweiden 6y agoI find rhysd/clever-f [1] to be more DWIM than Vim's default f/F. " 0: F is backward search, and repeating f after F searches in the same direction " 1: F is backward search, and repeating F after F searches in the same direction let g:clever_f_fix_key_direction = 1 [1] https://github.com/rhysd/clever-f.vim https://github.com/rhysd/clever-f.vim
- chongli 6y agoI try not to use vim plug-ins where built in functionality will suffice. I’ve trained vim’s default behaviour into my muscle memory so I’m fine with it. In fact, I used plain old vi (technically Keith Bostic’s nvi [1]) for years and sometimes I find myself preferring it. I think a lot of people who use vim end up with a ton of unnecessary plugins and they aren’t even aware of half the functionality of plain vi. I might just be a weird minimalist though. [1] https://sites.google.com/a/bostic.com/keithbostic/vi/ https://sites.google.com/a/bostic.com/keithbostic/vi/
- leephillips 6y ago
- hbofcator 6y agoI sort of got obsessed with the aforementioned ADM-3A keyboard layout, so I got myself a keyboard with unofficial QMK[1] support, and with that I remapped my keys as follows: - Tab functions as Escape, Caps Lock as Control. That makes both keys well in reach of my pinky, and I can still use ^I for Tab. - I remapped symbols according to an illustration[2] of the ADM-3A layout on Wikimedia (with some small adjustments). Aside from not having to press shift to enter command-mode, this also has the advantage of being more similar to the German layout, which I often have to use. - And finally I changed ^H and ^I to work outside of terminal emulators (i.e. they send keycodes for Backspace and Tab, respectively). While this layout is somewhat inconvenient for navigating CUA-derived UIs, I've found it great for use with vi clones and other TUIs. [1] https://qmk.fm/ https://qmk.fm/ [2] https://upload.wikimedia.org/wikipedia/commons/a/a0/KB_Terminal_ADM3A.svg https://upload.wikimedia.org/wikipedia/commons/a/a0/KB_Termi...
- kqr 6y agoI also remap shift-tab to tab in Vim, and then somehow manage to live without being able to actually shift-tab in Vim. I should probably think of some solution for that at some point...
- fizzled 6y agoI think this is a bad idea because remapping keys has significant consequences with compatibility as you develop across more platforms. A good vi user is trying to build universal muscle memory, and making personal exceptions kinda ruins the efficacy of the editor. For example: I switch between dozens of computers, some are transient VMs or cloud instances, and I cannot afford the time (or simply cannot alter the system) to set each one up to my personal VI specs. (Ironically, I'm a mac fan, but this is my biggest gripe going between every OS and Apple: the command key is absurd; I tried to remap to make everything work like Ctrl but that hoses the entire system and screws up VNC/RemoteDesktop...)
- njharman 6y agoYou should absolutely personalize tools you use extensively. Vim if your a writer or programmer. It’s very little to cp .vimrc. I do a lot more, have dotfiles git repo scripted to self install. But yes transient vms are problem. But I’m willing to suffer a little on them to have 20x more enjoyable and productive were I do 90% of my writing.
- wyclif 6y agoThe first thing I do on a new machine is clone my dotfiles from Github. It's fast enough for an action that increases my productivity exponentially and I'll end up saving back that time it took to clone very quickly. I don't switch machines that often anyway.
- SPBS 6y agoI wholeheartedly agree with this sentiment. I have a lot of keybindings but I always make sure I can survive without them, such as by dropping into vanilla vim to once in a while to do work and ensuring I'm not completely lost. A user in the vim subreddit refers to this as 'sharpening the saw'.
- samatman 6y agoI haven't done this completely (I use the jk remap hack in preference to escape) but I agree with this in general. Emacs is an operating system, and vi is a language, which is widely "spoken". But if you invent your own dialect, you have an MxN problem, of getting M changes to register across the N programs which will listen to you when you speak to them in vi. And I simply must nibble the bait in your last line: As a Mac native user, the command key, and consistency in commands across every native application, is one of the great features. It means, among other things, that Ctrl-whatever won't be intercepted when I send it to a program that uses it, or alternately, that it won't shadow the OS level affordance. Back when I was spending five days a week inside a Linux VM, the context switch between Cmd-X and Ctrl-X for cut was pretty rapid and painless. Sure, I'd get the occasional cache miss, but that's harmless.
- keithnz 6y agomy leader character is space, makes things super easy