You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Choose the test file and press <CR> to enter the test file.
echo b:match_skip returns:
E121: Undefined variable: b:match_skip
Screencast.From.2026-08-09.15-21-29.mp4
Because when netrw enters a file, it uses filetype detect to initialize native or remote files. filetype detect will trigger FileType * again, which calls LoadFTPlugin(). It will execute b:undo_ftplugin.
..." Moved the filetype detect here from NetrwGetFile() because remote files" were having their filetype detect-generated settings overwritten by" NetrwOptionRestore.if &ft!="netrw"filetypedetectendif...
defLoadFTPlugin()
ifexists("b:undo_ftplugin")
# We assume b:undo_ftpluginis using legacyscriptsyntaxlegacyexeb:undo_ftpluginunlet!b:undo_ftpluginb:did_ftpluginendifvars=expand("<amatch>")
ifs!=""if &cpo=~# "S"&&exists("b:did_ftplugin")
# In compatiblemodeoptions are resetto the globalvalues, need to
# set the local values also when aplugin was already used.
unletb:did_ftpluginendif
# When there isa dot it is used to separate filetype names. Thus for
# "aaa.bbb" load "aaa"and then "bbb".
for name insplit(s, '\.')
exe'runtime! ftplugin/' .. name .. '.vim ftplugin/' .. name .. '_*.vim ftplugin/' .. name .. '/*.vim'endforendifenddef
If commands in b:undo_ftplugin are the same as the variables or options initialized by users, they will be undone and initialized back to the values from the built-in ftplugin file. This breaks user updates.
This is especially problematic in LSP scenarios. It often conflicts with some settings in built-in ftplugin files, such as omnifunc, formatexpr, and foldexpr.
btw NerdTree not have this problem, because it use :edit to enters file.
Expected behaviour
netrw won't be use filetype detect to re-treggier autocmd FileType
Version of Vim
:version VIM - Vi IMproved 9.2 (2026 Feb 14, compiled Aug 1 2026 21:48:38) Included patches: 1-892
Steps to reproduce
:echo b:match_skipreturns10.Run:
:Explore<CR>Choose the test file and press
<CR>to enter the test file.echo b:match_skipreturns:Screencast.From.2026-08-09.15-21-29.mp4
Because when netrw enters a file, it uses
filetype detectto initialize native or remote files.filetype detectwill triggerFileType *again, which callsLoadFTPlugin(). It will executeb:undo_ftplugin.If commands in
b:undo_ftpluginare the same as the variables or options initialized by users, they will be undone and initialized back to the values from the built-in ftplugin file. This breaks user updates.This is especially problematic in LSP scenarios. It often conflicts with some settings in built-in ftplugin files, such as
omnifunc,formatexpr, andfoldexpr.btw NerdTree not have this problem, because it use
:editto enters file.Expected behaviour
netrw won't be use
filetype detectto re-treggier autocmdFileTypeVersion of Vim
:version VIM - Vi IMproved 9.2 (2026 Feb 14, compiled Aug 1 2026 21:48:38) Included patches: 1-892
Environment
Linux debian 7.1.3+deb14-amd64 #1 SMP PREEMPT_DYNAMIC Debian 7.1.3-1 (2026-07-04) x86_64 GNU/Linux
Logs and stack traces