Search code examples
vimkey-bindingsnetrw

When in Explore window of vim, window navigation mapping <C-l> stops working


I use the following vimrc configuration to navigate between panes:

" easier window navigation
nnoremap <C-j> <C-W><C-J>
nnoremap <C-k> <C-W><C-K>
nnoremap <C-l> <C-W><C-L>
nnoremap <C-h> <C-W><C-H>

This works fine with the exception when I'm in a :Explore window to do some file exploration.

All bindings besides <C-l> still work. But trying to navigate to the right with <C-l> stops working. I than have to use <C-W><C-l> to get out of the pane.

What do I possibly have to add or deactivate to make this work?


Solution

  • As can be seen in :help netrw-browse-maps, the Netrw buffer has its own buffer-local mapping to <C-l> that overrides yours.

    You can override Netrw's mapping with :help netrw-usermaps but it is at the cost of losing the ability to refresh the listing:

    let g:Netrw_UserMaps = [["<C-l>","MoveCursorToWindowOnTheRight"]]
    function! MoveCursorToWindowOnTheRight(islocal)
        return "wincmd l"
    endfunction