1

I wonder why netrw (:Explore) is not loaded after starting vim using vim -u NONE.

Inspecting my runtimepath yields: /Users/shuz/.vim,/usr/share/vim/vimfiles,/usr/share/vim/vim82,/usr/share/vim/vimfiles/after,/Users/shuz/.vim/after

, so common Vim directories are indeed present in the runtimepath.

If not the runtimepath, what mechanism causes netrw to be loaded?

3

netrw is a plugin, just one that is distributed with vim itself. For me, :Explore and friends are defined in /usr/local/share/vim/vim82/plugin/netrwPlugin.vim.

From the load-plugins section of :h initialization, step 4:

  1. Load the plugin scripts.

This does the same as the command:

:runtime! plugin/**/*.vim

The result is that all directories in the 'runtimepath' option will be searched for the "plugin" sub-directory and all files ending in ".vim" will be sourced (in alphabetical order per directory), also in subdirectories. However, directories in 'runtimepath' ending in "after" are skipped here and only loaded after packages, see below. Loading plugins won't be done when:

  • The 'loadplugins' option was reset in a vimrc file.
  • The |--noplugin| command line argument is used.
  • The |--clean| command line argument is used.
  • The "-u NONE" command line argument is used |-u|.
  • When Vim was compiled without the |+eval| feature.

Therefore, netrw is not loaded with -u NONE.

2
  • Thank you. Do you know why :Explore isn't loaded after executing :runtime! plugin/**/*.vim after starting Vim as vim -u NONE?
    – Shuzheng
    Feb 24 at 12:52
  • That's because if you look at the first few uncommented lines of netrwPlugin.vim, it doesn't load the plugin if compatible is set (the default). It will load if you do vim -u NONE, then :set nocompatible | runtime! plugin/**/*.vim. Of course, whether or not that's the right thing to do depends on what you are ultimately trying to achieve. Feb 24 at 13:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.