I want to map a keybinding to a command which includes <C-U>
not for clearing the command line but for scrolling the page up. Executing a command like this in my vim session works totally fine:
:exe "normal \<C-U>"
But when I try to map something to the exact same command in my .vimrc
, it doesn't work:
" My .vimrc
nnoremap <leader>u :exe "normal \<C-U>"<CR>
Now when I do <leader>u
it leaves :"
in my status bar which indicates <C-U>
is clearing the line instead of scrolling the page. What is the problem?
Edit: I oversimplified the keybinding that I'm actually using to only point to what causes the problem and avoid confusion. I am using <C-U>
in the context of a much more complicated keybinding but I need it to mean "scroll-up" instead of "clear the line." I'm using this binding nnoremap <leader>wu :<C-U>call win_execute(win_getid(winnr('#')), ":exe 'normal \<C-U>'")<CR>
to scroll another window without switching directly to it. I already used it with <C-D>
for scrolling down and it works perfectly fine but this one doesn't work because of the other meaning that <C-U>
has in command mode.