0

I'm tuning :sp, :vsp things, and for example I have:

nnoremap <nowait> <C-L> <C-W><C-L>
nnoremap <nowait> <C-W><C-L> :vsp<CR><C-W><C-L>

Since I only want <C-W><C-L> sequence, i.e. if I type too fast (should no be a problem, as we're vim users), the sequence probably reversed to <C-L><C-W>, important part: since I have <nowait> <C-L>, I guess the only thing slow me down is <C-W>. So is it possible to have a map like

nnoremap <C-W> <NULL>           " When I keep <C-W> pressed I want it do nothing.
nnoremap <nowait> <C-W><C-L> \  " I want to keep this combination.
                  :vsp<CR><C-W><C-L>

Btw, if I add <nowait> to it, would the <C-W><C-L> never be triggered?

2

After some try-and-errors I resolved this problem.

  1. Btw, if I add to it, would the never be triggered?

    Yes.

  2. Change nnoremap <C-W> <NULL> to:

     nnoremap <C-W> <ESC>
    

    Since normally no key will follow <ESC>. (Remember when you were a newbie and wanted to escape from it)


Result, done in 1 second:

enter image description here

3
  • 2
    Your mappings sounds like a good way to ask for trouble. IMHO you should not try to change the behavior of <C-W><C-L> that will bite you in the future. But anyway you are probably looking for <NOP> instead of <Esc> :h <Nop>
    – statox
    Apr 2 at 15:58
  • @statox: You comment deserves an answer! Btw I just got bited since I have map <...> <C-W>... and since I mapped <C-W> to <ESC>, it will modify the document I just open when I enter it!
    – job_start
    Apr 2 at 16:31
  • 1
    Feel free to add the <nop> thing to your answer, I'm pretty sure we have a duplicate of this question anyway :) And yes a good rule of thumb is not never remap an existing normal mode command (this is especially true for the <c-w> family) because 1) you often deprives yourself from a useful feature and 2) you are likely to break other things which will be painful in the long term. Prefixing your mapping with <leader> is often a good solution if you can't find an empty mapping which works for you.
    – statox
    Apr 2 at 17:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.