Problem
Opening a file from a netrw listing throws:
Error in function <SNR>NN_NetrwBrowseChgDir:
line 120:
E471: Argument required: keepj keepalt 2wincmd 1
whenever g:netrw_chgwin == winnr('$') + 1. The easiest way to hit it:
:Lexplore (sets g:netrw_chgwin = 2) and open a fileg:netrw_chgwin stays 2):Explore in the remaining single window and press <CR> on a fileRoot cause
In s:NetrwBrowseChgDir (runtime/pack/dist/opt/netrw/autoload/netrw.vim:3939), the "make the missing window available" branch builds the return jump as:
exe "NetrwKeepj keepalt ".g:netrw_chgwin."wincmd ".curwin
which concatenates the saved window number (curwin) where wincmd expects its single-letter argument — producing the malformed 2wincmd 1.
Fix
Per the surrounding comment, the intent is to return to the saved window after vs creates the missing one; the statement right after the endif then performs the actual jump to g:netrw_chgwin:
exe "NetrwKeepj keepalt ".curwin."wincmd w"
Verified (nvim 0.12.4 with the patched file shadowing the bundled copy, same runtime code): the repro above no longer errors; the selected file opens in window 2 of a fresh vsplit, i.e. the documented g:netrw_chgwin behavior.
Notes
runtime/autoload/netrw.vim:4976 at v9.0.0000).https://github.com/vim/vim/pull/20741
(1 file)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()