0

I have modified the 'runtimepath' in my .vimrc file. As I am having problems of not found files, I would like to display the runtimepath value in an :echo or :echomsg

I already know about the existence of :scriptnames and the possibility of checking the value with :set runtimepath, but I specifically need to display it with :echo or :echomsg commands.

I have already tried, without success, the following:

  • :echo runtimepath
  • :echo expand(runtimepath)
  • :echo expand('runtimepath')
1
  • Nothing that can't be found with a simple :help :echo.
    – romainl
    Commented Apr 30, 2023 at 9:02

2 Answers 2

2

Everyting that is set using :set is an option in vim. Options are described in the help between single quotes, like in :h 'runtimepath'

If you check the documentation page :h after-directory, it is said:

More entries are added when using |packages|. If it gets very long then :set rtp will be truncated, use :echo &rtp to see the full string.

Therefore, the answer to the question is:

:echo &runtimepath

As suggested by @d-ben-knoble in the comments, this approach creates a new buffer and reports in a much more legible way as each path is in a different line

:new | put =split(&runtimepath, ',')

Output is like

C:\Users\myusername/vimfiles
C:\Program Files (x86)\Vim/vimfiles
C:\Program Files (x86)\Vim\vim90
C:\Program Files (x86)\Vim\vim90\pack\dist\opt\matchit
C:\Program Files (x86)\Vim/vimfiles/after
C:\Users\myusername/vimfiles/after
0
2

There is another way that may be easier depending on the situation.

Sometimes I do things like this with the expression register (:h @=) knowing that settings can be accessed from expressions using a leading & (from :h expression-syntax in the expr10 section in my version)

While in insert mode:

<c-r>=&runtimepath<cr>

You could make it "clean" by combining with the split in @aturegano's answer:

<c-r>=split(&runtimepath, ',')<cr>
1
  • 1
    This is useful in Insert mode! The other answer has the benefit of being readily accessible in Normal mode, which is the mode I'm in normally :)
    – D. Ben Knoble
    Commented Apr 30, 2023 at 18:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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