5

I recently stubled upon a feature in netrw that's called netrw-C. From the docs:

SETTING EDITING WINDOW                  *netrw-C* {{{2

One may select a netrw window for editing with the "C" mapping, or by setting
g:netrw_chgwin to the selected window number.  Subsequent selection of a file
to edit (|netrw-cr|) will use that window.

Related topics:         |netrw-cr|
Associated setting variables:   |g:netrw_chgwin|

I've managed to achieve the described behavior by manually setting g:netrw_chgwin but I couldn't understand or find how that "C" mapping works.

Yes, I could just map

:let g:netrw_chgwin = winnr()

but I'm curious how the original netrw-C mapping works.

Does anybody know how to use the "C" mapping described in the docs?

Nikita
  • 1,053
  • 1
  • 10
  • 19
  • Haha. I've been scratching my head for 3 years about that mapping without ever thinking about asking anybody. – romainl May 27 '13 at 20:05
  • netrw is designed to support having multiple windows with netrw directory displays showing. Pressing "C" in one of those netrw windows will make it the preferred editing window. – user21497 Apr 01 '15 at 15:57

1 Answers1

2

While inside netrw the C mapping looks like its just mapped to

:let g:netrw_chgwin = winnr()

If you do a :map C you will get the output

n  C           *@:let g:netrw_chgwin= winnr()<CR> 

From :h map-listing

Just before the {rhs} a special character can appear:
    *       indicates that it is not remappable
    @       indicates a buffer-local mapping

So C is the same as :let g:netrw_chgwin= winnr()<CR> that is just local to the netrw buffer.

FDinoff
  • 30,689
  • 5
  • 75
  • 96