Here's an interesting usage that I first saw (and wandered about) in Shougo's Unite plugin, which creates an artificial leader key "placeholder" (I'm quoting directly from the Unite's help file):
" The prefix key.
nnoremap [unite] <Nop>
nmap f [unite]
nnoremap <silent> [unite]c :<C-u>UniteWithCurrentDir
\ -buffer-name=files buffer bookmark file<CR>
... (etc.)
In the above example, the whole sequence of characters [unite]
is mapped non-recursively in normal mode to do nothing (and thus, it becomes a "prefix"!) Then, a "leader" key is assigned to this complicated <Nop>
; in this case, f
.
What follows are the actual maps, in which every time you type f
<some other char(s)>
, Vim translates it to [unite]
<some other char(s)>
-- if the combination is defined (and typed in time), the map gets executed, otherwise -- the prefix is cancelled (because it gets resolved by itself to <Nop>
, i.e. nothing) and it's like you didn't type it at all. Mind boggling.
I didn't test, but I think the way the sequence itself is defined (here, [unite]
) is quite relevant -- if I got it right, it will create delays for any key combinations starting with [
, [u
, [un
and so on. So you would always want to use a leader placeholder "string" that starts with characters you don't normally (pun) use by themselves.
:h <plug>