3

I have these in my .vimrc:

set notimeout
nnoremap <leader>n :set rnu!<CR>
nnoremap <leader>h :<C-u>call Toggle_colorcolumn()<CR>

<leader>n works instantly; <leader>h waits until I press Return or Escape key. Why does vim wait? I want it to take effect immediately.

This is the function definition just in case the problem is there:

function Toggle_colorcolumn()
    if &colorcolumn != 80
        exec('set colorcolumn=80')
    else
        exec('set colorcolumn=0')
    endif
endfunction
  • 1
    Welcome to Vi and Vim! Just FYI, your code can just use set colorcolumn=80 directly. It’s an ex command. – D. Ben Knoble Jan 6 at 23:10
  • @D.BenKnoble Thanks both for the tip and welcoming me. – S.Rad Jan 7 at 2:29
2

I had another binding that <leader>h was a prefix and I had forgotten about; it was <leader>html. Removing it solved the problem.

| improve this answer | |

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.