Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

(Funnily enough ctrl-[ is one of my most used shortcuts in vim. It’s a convenient alternative to escape if you map caps-lock to ctrl)


Even better: map held Caps to Ctrl and a tap of Caps to Esc


I map held Caps to Super (so I can switch windows and use other higher-than-application-level shortcuts without leaving the home row in dwm), but yes, definitely don't limit yourself to one use for your keyboard's most convenient key without a use. In X11 it's as easy as

    setxkbmap -option caps:super
    xcape -e 'Super_L=Escape'
(where setxkbmap is built into X, and xcape is a one-command install away). And IIUC you can do this with ~6 clicks in a third-party GUI like https://karabiner-elements.pqrs.org/docs/manual/configuratio... in macOS.


I really don't like chord like shortcuts, while ctrl and [ are positioned in a way you don't have to contort your hand it kind of requires you to move away from the hjkl row or stretch your pinkies. Consider mapping esc to jk (as a sequence) it works surprisingly well.

  inoremap jk <esc> 
and

  inoremap <esc> <nop>
so that you never use esc again

not having chord like shortcuts was one of the main reasons that led me to try vim over emacs in the beginning, so I kind of think they're "anti" vim.


I've been using ctrl-[ for years, but have been experimenting with jj. Now I'm not sure which one I like better!

I switched back to vim+tmux (nvim) a few weeks ago from a number of years using vs-code with the vim keybindings.

I'm still trying to configure my plugins so that I don't feel like I'm repeating myself too often.


Having ctrl-[ in your muscle memory has the advantage that it also works in other readline programs that have a vi like interfacee, e.g. bash, zsh and many db consoles.


I recommend mapping jk to esc in insert mode (instead of jj), so you remain on the same line if you accidentally use it in normal mode.


Note, don't do this if you're Dutch, words with 'jk', or rather 'ijk' in them are annoyingly common.


This is now my muscle memory escape key since an embarrassingly cheap Bluetooth keyboard of mine only allowed escape == home button on my Android devices.

Pro Tip: Park the flesh of your left palm near the left ctrl key and use that instead of your pinky for ctrl. I admit this feels a bit weird at first but avoids the need to lift your fingers from the home row. Super bonus: use ^H for backspace. Try it out!


Note: Often Ctrl-3 does the same thing.


That's excellent!

That gives a left handed option for escape without leaving the home row. I really like having mirrored shortcuts like that, thank you.


Omg that is such a game changer for me. way more ergonimic than hitting esc


You may be using vim wrong. Good for you if you like it that way


You're going to have to explain that one because I generally switch back to command mode after every edit so I use ctrl-[ a lot.

I'd be VERY interested to hear why that's wrong and what you do differently.


my reasoning was : you could have mapped caps lock to ESC but you did not. So maybe you are using CTRL too much (CTRL-V maybe?) which is not the best way to use vim.


No your reasoning is way off. I map to ctrl rather than escape because I want to make use of the Insert and Ex mode ctrl shortcuts.

For example, if I want to insert a register into the ex mode command line I use ctr-r <register>.

Or if I want to pop out of insert mode for a single command I use ctr-o.

E.g. inserting opening and closing tags when a suitable plugin isn't present. Insert the opening and closing tag, jump back to command mode with ctrl-o, move backwards and you're ready to insert more text.


Can't speak for everyone, but I use this[1] keyboard most of the time, and it doesn't have a Caps Lock key to remap, but instead has Control where Caps Lock normally is. So using ctrl-[ is much easier than reaching up to the escape key.

[1] https://hhkeyboard.us/pro-classic/


Using Ctrl-[ is perfectly fine if that's convenient to you. Some people doe "inoremap jj <esc>" and double tap j to exit insert mode. If it's faster for you than pressing regular escape, it's an improvement, and thus good.


Politely, I'd consider rephrasing this in the future. Not everyone springs forth into the world with a 5kloc .vimrc. Everyone is incrementally learning from someone else at their own pace.


I'll do. Thank you. I did not realise I was mean because english is not my native language




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: