[vim/vim] Installing the built-in matchit plugin using the documented approach does not work (Issue #9389)

350 views
Skip to first unread message

jwdevel

unread,
Dec 22, 2021, 2:24:27 PM12/22/21
to vim/vim, Subscribed

Steps to reproduce

  1. Run vim --clean
  2. Type what the documentation recommends, to enable matchit: :packadd! matchit
  3. Type: :echo exists("loaded_matchit"), or something similar like :echo g:loaded_matchit
  4. The result indicates the plugin is not loaded

Expected behaviour

The plugin should be activated, since that's what the docs say.

Quote from :help matchit-install:

To start using the matchit plugin, add one line to your vimrc file:
packadd! matchit

Version of Vim

8.2, patches 1-2914

Environment

Debian 10.11

Logs and stack traces

Note: it *does* work to install the plugin like so:

`:runtime macros/matchit.vim`

Apparently that is the old, pre-8.0 way of doing things? I found out about that from reading the answers to [this SO post](https://stackoverflow.com/questions/7281459/matchit-not-working).

So, either there is some bug with `packadd`, or with how `matchit` is bundled in Vim currently, or the docs are simply wrong and the `:runtime ...` command is the proper way. I'm not sure which is the case.


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/9389@github.com>

lacygoill

unread,
Dec 22, 2021, 2:34:37 PM12/22/21
to vim/vim, Subscribed

The help says to write this line in your vimrc; not to execute it interactively from the command-line:

To use the matchit plugin add this line to your |vimrc|: >
packadd! matchit

With a bang, :packadd only manipulates the runtimepath. That works when the vimrc is being read, and the plugins have not already been sourced. After that, it's too late.

If you want to enable the plugin after Vim has started, you need to remove the ! from :packadd:

:packadd matchit

For more info, see :help :packadd:

When the optional ! is added no plugin files or
ftdetect scripts are loaded, only the matching
directories are added to 'runtimepath'. This is
useful in your .vimrc. The plugins will then be
loaded during initialization, see |load-plugins| (note
that the loading order will be reversed, because each
directory is inserted before others).


If this needs to be documented, then here is a suggested patch:

diff --git a/runtime/pack/dist/opt/matchit/doc/matchit.txt b/runtime/pack/dist/opt/matchit/doc/matchit.txt
index 7b2b92111..ae0cde7db 100644
--- a/runtime/pack/dist/opt/matchit/doc/matchit.txt
+++ b/runtime/pack/dist/opt/matchit/doc/matchit.txt
@@ -148,6 +148,9 @@ To use the matchit plugin add this line to your |vimrc|: >
 
 The script should start working the next time you start Vim.
 
+To use the matchit plugin after Vim has started, execute this command: >
+	packadd matchit
+
 (Earlier versions of the script did nothing unless a |buffer-variable| named
 |b:match_words| was defined.  Even earlier versions contained autocommands
 that set this variable for various file types.  Now, |b:match_words| is


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/9389/999816294@github.com>

Bram Moolenaar

unread,
Dec 22, 2021, 3:49:40 PM12/22/21
to vim/vim, Subscribed

Thus this is working as expected. I'll add that line to the help.


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/9389/999871813@github.com>

Bram Moolenaar

unread,
Dec 22, 2021, 3:49:42 PM12/22/21
to vim/vim, Subscribed

Closed #9389.


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issue/9389/issue_event/5806773591@github.com>

Christian Brabandt

unread,
Dec 23, 2021, 3:51:52 AM12/23/21
to vim/vim, Subscribed

I'll add this to my copy as well


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/9389/1000141839@github.com>

Reply all
Reply to author
Forward
0 new messages