r/neovim•
Redbeardt

Muscle Memory vs. Ctrl-C

If you're like me, not long ago you were using Ctrl-C as your escape-from-insert key. You stopped because you found that it was also occasionally an effective instantly-escape-from-nvim key.

If you're especially like me, you are trying to get used to an alternative key but you keep accidentally hitting Ctrl-C, instantly killing your neovim. Muscle memory > me.

If you're on Windows, here's a tip! Use AutoHotkey to contextually disable Ctrl-C. I'm using WezTerm and it chucks the child process name on the end of the window title. I match against that and it blocks Ctrl-C only in neovim.

If you're on Linux, you have all the cool programs anyway. There's probably a dozen equivalents.

Sorry if this thread seems a bit superfluous. I was chuffed having thought to do this. n_n No more sudden exits for me!

PS: If you want to do something a little bit evil you could bind Ctrl-C to another rarely-used key in AutoHotkey then, in neovim, map that key to Esc. No more sudden exits, but you're still pressing Ctrl-C. Hmmm...

Posted Mar 22, 2022, 2:19 AM UTC

316
vividboarder•

I just started using Ctrl-[ instead. Similar enough that it was easy to transition to but much better for the purpose.

9
Hellvetian•

Map CAPS to Ctrl and replace the keys Esc (Ctrl-[), Enter (Ctrl-m), Tab (Ctrl-i) and Backspace (Ctrl-h)... Can be used in reasonable terminal emulators, too. I love it...

1
MouKuBi•

Thinkpad user here, ESC key is bigger than others in the keyboard. One key do one thing, sounds good for me.

4
RedbeardtOPset noexpandtab•

Honestly? I'm just too lazy to move my hand up the keyboard 5cm.

2
MouKuBi•

Yep, use thinkpad x series and vim for many years, 12.5", quite small, press ESC with little finger already became a muscle memory.

3
digitalMechanic42•

So you should use AutoHotKey (win) / Karabiner (Mac) to turn your caps lock key to an enhanced CTRL key; tap for ESC, hold for CTRL. Then you can really minimize your movement.

2
augustocdiaslua•

How about remapping the caps lock for it? Nobody uses it anyway. I have a friend that uses like this for the same reason as you.

2
RedbeardtOPset noexpandtab•

I could.. I've just been wondering lately whether it's better to try and get used to all the defaults so if I find myself having to nvim in the wild I can still do things. But maybe that won't happen.. In any case, I've been trying to get used to Ctrl-[.

1
Jeklah•

Now that is an awkward binding.

2
augustocdiaslua•

Why is Ctrl-C killing neovim?

3
RedbeardtOPset noexpandtab•

Buggered if I know! I was told this in another thread by u/TheLeoP23

That's what <c-c> does by defect on any terminal program, maybe the problem has something to do with your terminal (?)

And u/lukas-reineke said that I shouldn't use Ctrl-C anyway because it doesn't trigger the InsertLeave event.

3
EnderOfGenderPlugin author•

Ctrl-C escaping insert mode is not intentional, it is a by product of Ctrl-C being the terminal quit character. It's why Vim nags you about it by default, assuming your terminal didn't close Vim. Nano explicitly overrides this character to use Ctrl-C

1

I map A-j to Esc, just using thumb of left hand and index finger of right hand, no finger move!

1
yngwi•

This is a very interesting tip, thanks, I'm going to try this out. So far I tried to use jk but it just doesn't feel right...

1