Reputation: 981
<C-W><C-O>
or <C-W>o
invoke the vim single-window command which maximizes the current vim split, and annoyingly (if you keep typing it by accident) closes all others.
I want to remap it to <C-W><C-_>
which doesn't close other windows.
In .vimrc I have
map <c-w><c-o> <c-w><c-_>
map <c-w>o <c-w><c-_>
This works if I type C-W
and then o
or C-O
in quick succession.
However, if I type C-W
, then wait a second, and then type o
or C-O
the mappings I have set up are bypassed, and the single-window command is invoked.
Should I use some other map variation?
Upvotes: 3
Views: 917
Reputation: 79225
Another thing you can do is modify the 'timeout'
and 'timeoutlen'
settings:
For example :set timeoutlen=3000
will set the mapping timeout to 3 seconds instead of 1 (default).
Reference on :help 'timeout'
and :help 'timeoutlen'
.
Upvotes: 3
Reputation: 172698
The difference between mappings and the built-in two-key mappings like <C-w>o
is that the former timeout, whereas the latter wait indefinitely for the second key press. To completely override the behavior with a mapping, you'd have to define an (expression-) mapping for <C-w>
, and handle the second key inside the mapping with getchar()
(which also waits indefinitely).
But please think carefully whether such effort is really needed: If you're prone to fat-fingering keys or pressing the wrong ones, your use of Vim will be severely hampered. Better learn through the quick feedback that you've pressed something wrong, and try to work on improving your muscle memory!
Upvotes: 2
Reputation: 489
How about putting set hidden
into your .vimrc, so after closing all the splits they don't get closed, only put to background? After that you can list all the opened buffers via :ls
command for example.
But regards to your mapping, maybe you could try unmapping (or yet even better nunmap - which unmaps a command only in normal mode) o first, and then map it.
Upvotes: 1