
Vim: Spacebar as leader key, CapsLock as Esc - normalocity
http://karmanebula.com/technically-borked/2013/12/16/leader-key-as-space-capslock-as-esc
======
kps
_Perhaps I have spent so much time on Mac that pressing the Ctrl key for
things feels unnatural vs. the Command key_

Argh. OS X is the last significant platform that gets this right by not trying
to use Control for menu shortcuts out of the box. When I'm in a terminal, or
editor, or browser text box, it's perfectly common and reasonable to want to
distinguish Control-V (literal) from Command-V (paste), Control-Z (suspend)
from Command-Z (undo), and so on.

Pre-Linux X Window software typically managed this, using Meta or some other
keysym for GUI operations, but current ‘desktops’ seem dead set on imitating
MS Windows. Damn kids get off my screen.

~~~
normalocity
I think this is one of the main reasons I went with space in this case.
Hitting a shortcut starting with a key that either thumb can reach felt more
like the Command key, which is part of why I like it. It seems that my thumb
is more nimble (and has a much higher range of motion) than my pinky.

------
karmajunkie
I basically do this, but I use "," (comma) as my leader, and I make capslock
do double duty as ctrl and esc using KeyRemap4MacBook
([https://pqrs.org/macosx/keyremap4macbook/](https://pqrs.org/macosx/keyremap4macbook/)).
The trick is first remap capslock to Ctrl in keyboard system preferences, then
use KR4MB to remap Control_L (the left control key, which is to say, what
capslock now signals) to Control_L, but if you type ONLY Ctrl_L it sends esc.
so when i need escape, it sends that. when i want to use it for Ctrl-modified
combos, it does that. Works fantastically for Vim, i've been doing this for a
couple years now. Also nice for emacs keyboard shortcuts in other apps that
respond to them.

~~~
theOnliest
This is what I do too: Caps Lock sends either Escape (when pressed alone) or
Control (with something else). I cribbed it from Steve Losh:
[http://stevelosh.com/blog/2012/10/a-modern-space-
cadet/](http://stevelosh.com/blog/2012/10/a-modern-space-cadet/).

------
rc4algorithm
To the many of you using Macbooks: be aware the that the caps lock key is
deadened/delayed in order to prevent mistaken pressing, and that this is a
hardware feature that can't be changed. This may be the case for Mac keyboards
and other new systems as well.

------
q_revert
I use <space> as my Easymotion leader..

[https://github.com/Lokaltog/vim-easymotion](https://github.com/Lokaltog/vim-
easymotion)

it's well worth a look, gives you super quick fine grained movement

similarly

    
    
        inoremap jj <ESC>
    

to take you from INSERT mode to NORMAL mode is nice

~~~
eridius
I've been using

    
    
        inoremap jk <ESC>
    

for a long time now, and it works like a charm.

~~~
msutherl
Likewise. Started with 'jj', but 'jk' is significantly faster. Only downside
is that you can't actually type 'jk'. Now everybody thinks I'm serious all the
time.

~~~
recuter
twiddle with the timing settings (I forget). So typing 'jk' _only_ very
quickly indeed will register as ESC.

------
SmileyKeith
I use CapsLock as escape but had I not gotten so used to that by now I would
probably have used it for control instead and mapped escape to jk or
something. I, like many people, use `,` for my <leader> and with Clever-F[0] I
don't lose the original functionality which is just remapped to consecutive
presses of 'f'.

[0]:
[https://github.com/rhysd/clever-f.vim](https://github.com/rhysd/clever-f.vim)

------
jfft
Love spacebar as the leader key, but not a fan of CapsLock as Esc. CapsLock as
Ctrl is better. For one, you never have to stretch for the real Ctrl, and two,
you _can_ use it for escape as well: Ctrl-[

~~~
e12e
> and two, you can use it for escape as well: Ctrl-[

Sadly, not (sanely) with a Norwegian keyboard layout. We "only" have one key
left of z, namely "<" (and with shift ">") -- and not really any keys right of
"l" and "p" \-- right home-row is "jklø" followed by "æ", and "å" is right of
"p".

Way out in the cold by the enter key we have "'" (shift for "*"), and the not-
so-useful composing '"' (and "^~" with shift/alt-gr respectively).

If only we could stick to something like romaji'zed Japaneze, we'd have plenty
of keys left over! ;-)

------
jdonaldson
I broke things down by priority. I notice that I jump around in documents by
searching through them, rather than by navigation keys. Spacebar is the
biggest key on the keyboard, so, spacebar is mapped to "?" in normal mode. I
also find that I need to search through a project regularly, so ctrl-spacebar
is mapped to the ack/ag command.

Control is mapped to caps lock at the os level for me. There are also too many
useful commands in vim that use control (visual block mode is huge). I tried
mapping jj to escape as well, but ctrl-c is just as easy.

Leader is mapped to comma. Most of my leader commands are comma + "some letter
I can type with my left hand".

~~~
justinmk
> I jump around in documents by searching through them

You might want to try vim-sneak.

[https://github.com/justinmk/vim-sneak](https://github.com/justinmk/vim-sneak)

------
glynch
I prefer remapping capslock to control for easier use of commands like <C-f>,
<C-b>, <C-e>, <C-h>, and <C-l> (all of which were absent in the example vimrc
posted). Using the leader key makes total sense for dealing with splits and
buffers or plugins you might want to look into some of the other Control based
commands that Vim supports.

~~~
normalocity
I use Ctrl-f and Ctrl-b (as well as Ctrl-e and Ctrl-y) pretty often, and
you're right that there are no shortcuts for it in the provided example.
Perhaps I should look into those as possible next targets. I guess I'm not
entirely eliminating the Ctrl key from my vim usage (not that there's anything
wrong with Ctrl, really), but you have a point.

I'm guessing I use Ctrl-e more often than :e - perhaps I should change that
up.

There seems to be a lot of ringing endorsements for CapsLock as Ctrl in the
comments.

------
munger
Thanks for the easy-to-understand take on the leader key. Not using the leader
key is one of my known vim weaknesses I've been meaning to fix. I found your
explanation and usage a great push into actually putting it in my .vimrc

------
CGamesPlay
I end up using Ctrl for a bunch in vim: visual block, ctrlp (and <C-b> for
buffer mode), window nav, and most importantly, imported emacs keybindings.
The emacs line motion commands (specifically <C-a>, <C-e>, and <C-d>) are
extremely useful because they work in every app on my mac, so not having to
lose flow when I'm in vim or a browser is nice.

[https://github.com/CGamesPlay/dotfiles/blob/master/files/vim...](https://github.com/CGamesPlay/dotfiles/blob/master/files/vimrc#L152)

------
Theodores
If I am going to have to relearn where some of the keys are in vim then I
might as well go the whole hog and get a Dvorak keyboard whilst I am at it!

~~~
normalocity
lol - well, it's just an option. Certainly less invasive than changing the
keyboard layout, but I understand the muscle memory element of it.

I definitely stuck with the default vim bindings (and for the most part can
switch back to them quickly) until I wanted to customize the experience to my
preferences. There's definitely something to be said about keeping the stock
bindings unchanged, if that's one's preference.

------
sethish
I've been using this since
[~2010]([https://github.com/sethwoodworth/dotfiles/commit/801f4a7163d...](https://github.com/sethwoodworth/dotfiles/commit/801f4a7163db017c0be7edaee2e358b7f3d4bf50#diff-4e12c6a37ff2cbb2c93d1b33324a6051R77)).
I highly recommend leader as space.

------
svermeulen
Why not map caps lock key to both escape AND control? I've been doing this
successfully for a long time and couldn't live without it. You can use
Autohotkey on windows and similar tools on other systems to interpret caps
lock pressed by itself as escape, and caps lock pressed + another key as
control.

------
97-109-107
The is a way of minimizing the frequency of having to reach esc (be it at esc
or caps lock) " jj For Quicker Escaping between normal and editing mode.
inoremap jj <ESC>

------
jagger27
What is a leader key? How much typing class did I miss?!

~~~
ryanthejuggler
I think he means instead of using a colon to begin Vim commands, he begins by
typing a space.

I started using Caps Lock as an extra Ctrl a couple months ago. It's great,
except now I can't use other people's computers because I end up in caps-lock
shout mode.

E.g. instead of "ctrl+l" in my browser to visit a site, it ends up:

    
    
        CTRL+SHOUT+L BROWSER TAKE ME TO FACEBOOK I COMMAND THEE

~~~
publicfig
Leader is actually a different key than the colon in Vim. Here's a nice
description of it:
[http://learnvimscriptthehardway.stevelosh.com/chapters/06.ht...](http://learnvimscriptthehardway.stevelosh.com/chapters/06.html)

------
etanazir
I use ',' and my leader; but have been considering remapping 'esc' ... any
suggestions other than CapsLock?

~~~
ChronosKey
jj is what I use and is also pretty common. Some other suggestions:
[http://vim.wikia.com/wiki/Avoid_the_escape_key](http://vim.wikia.com/wiki/Avoid_the_escape_key)

------
ryan-thompson
I love this idea, I never thought of using the spacebar as anything other than
a space.

------
erikb
Nobody said it yet, so I have to do it: Happy Hacking Keyboard

------
harryovers
i have capslock as my backspace key. where do i put escape now?

------
knodi
i use my caps as control key.

