savory code and other culinary highlights

Vim: Staying on the Base Line

Staying on the touch-typing base line (a, s, d, f, ..) is strongly promoted by the Vim movement keys - but :w, ctrl, escape and more tend to distract my hand position. Here are some of the steps I took to deal with this:

map , to Leader

map Space to ^

map Control-m to save all

dual-map Caps Lock

map jj to Escape in insert mode

remap window focus movement

map Escape-Escape to nohlsearch

map , to Leader

Most people remap the leader key, so I’ll not lose many words on this:

1

let mapleader=','

map Space to ^

Space is a big key (actually, two keys because both thumbs can use it) and it’s obvious that it should be mapped
to something useful/often-used.

There’s a lot of possibilities, some interesting ones to get you started:

Leader

repeat last macro

nohlsearch

save-buffer

page-down

colon

My current favorite is “jump to indent-start”:

1

map <Space> ^

I’m still evaluating binding it to page-down or to :, although I’m pretty happy about getting rid of the ^ key!

map Control-m to save-all

I almost never selectively save single buffers since all my files are version controlled and there’s an undo queue. This binding will eliminate a very common use of the : key, which is straining both pinkies.

1

nmap <silent><C-m> :wa<CR>

dual-map Caps Lock

Many people map CapsLock to Escape. Other people map it to Control. Both mappings substitute the use of a
difficult to reach key.

You can get the best of both worlds by mapping a tap to Escape and a hold to Control,
since the control key is only used as a modifier and the Escape key is never used as a modifier.

I added the sudo make install line to have it available system-wide.
Now let’s use it:

1

xcape -t0-e'Control_L=Escape'

The zero timeout value is important since else it would sometimes interpret leaving insert mode and
pressing another key as a Ctrl-? combination if you’re too quick.

This command is not persistent, so if you have tested it out and like the way it works, append the above line to your .bashrc or .profile file.

map jj to Escape in insert mode

1

inoremap jj <Esc>

This is really cute and it’s been sitting in my .vimrc for quite some time now. But I have to admit that I’ve never
used it - I probably should, though, since this will greatly reduce the strain on my left pinky.

remap window focus movement

Moving between windows is awkward with most configurations.

I was using \<Leader>-W as my window command initiator, but this is still a lot of keypresses just for jumping with
your cursor.

Using Control+Movement keys to jump intuitively between window splits seems to be a nice idea, but for me this only became viable once I moved the Ctrl key to CapsLock (as described above).