I created following shortcut for vim command in .vimrc:
:nnoremap <Leader>1 :set foldexpr=getline(v:lnum)=~'^\\s*$'"
But the shortcut doesn't work. The shortcut doesn't work if I change 1 to, say, w. However, the shortcut works if I map the command like this:
:nnoremap <F5> :set foldexpr=getline(v:lnum)=~'^\\s*$'"
My question is why the shorcut doesn't work for <Leader>1 but works for <F5> and is there a way to make it work with <Leader>?
:let mapleadershould show you the key used as the leader – statox Apr 01 '21 at 13:47<CR>at the end of the mapping... As it is, it would just leave the:setcommand in the Ex command line waiting for you to execute it by pressing the "Enter" key. Is that intended? Is that the issue? (Not sure why this would not be the case with F5, but it's possible it produces a long sequence that leaves something close to a<CR>at the end...) – filbranden Apr 01 '21 at 14:16