0

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>?

ewr3243
  • 131
  • 3
  • 1
    Are you sure you are using the correct leader? :let mapleader should show you the key used as the leader – statox Apr 01 '21 at 13:47
  • 2
  • Leader key is correct. Other shortcuts work. – ewr3243 Apr 01 '21 at 13:53
  • You're missing a <CR> at the end of the mapping... As it is, it would just leave the :set command 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

0 Answers0