I experimented with a few different Vim mappings to make it more comfortable and eventually landed on the following in my
" type ctrl+return to start a new line with |> inoremap <buffer> <F13> <ESC>o\|><space> nnoremap <buffer> <F13> o\|><space> " type ctrl+\ to add an inline |> inoremap <buffer> <C-\> \|> nnoremap <buffer> <C-\> A<space>\|><space>
Now any time Vim receives an
F13 keypress, it creates a new line starting with
|> and I can start typing the next part of the pipeline.
F13? My keyboard stops at
F12! How is this better than manually starting a new line and typing
|>? Fortunately iTerm2 makes it easy to trigger
F13 with a custom Key Mapping.
[25~ if you're copying and pasting.)
As you can see, I've mapped
ctrl+return to send the escape sequence for
F13 in iTerm2.
Since I've rebound caps locks to control,
ctrl+return is a very convenient combo to press.
ctrl+\ is conveniently physically close to
ctrl+return so I find the mental mapping as a similar (but slightly different) concept both memorable and pleasing.
I'll admit this seems silly, but these sorts of optimizations for ergonomics keep things flowing.
If you're asking why I don't just map
ctrl+return in Vim itself, the answer is
that terminal Vim can't distinguish
ctrl+return from normal
this can vary by terminal emulator).
Do you have a better suggestion or use a similar approach for your preferred terminal emulator? Hit me up on twitter @semanticart.