26

I want to see the value of a variable, so I run the command

:let

Vim displays the results of this command using the --more-- pager.
How can I search this for a phrase, e.g. html?
I've looked the man page for the more pager which says +/ is used for search but it doesn't seem to work, neither does / as per the less pager.

4
  • 1
    AFAIK, it's a Vim internal command - it looks like 'more', but the program is not called by Vim (proof: it works in Windows, too). You can still write the beginning of a variable name, than ask Vim to complete it (e.g. with Ctrl-d).
    – VanLaser
    Dec 5, 2015 at 8:30
  • thanks, when I type the variable name - or in fact pretty much anything - vim wont accept it - it just prompts with -- More -- SPACE/d/j: screen/page/line down, b/u/k: up, q: quit in the commandline. Dec 5, 2015 at 8:34
  • 1
    Write :let then don't hit Enter, but Tab or Ctrl-d - you'll have a list of existing variables, displayed in "more" style - now hit Esc, write a few letters, hit Tab or Ctrl-d again ... and so on until you find the variable you want. Actually, to see the value of a variable, perhaps you should use echo instead? (Or set variable-name? for options)
    – VanLaser
    Dec 5, 2015 at 8:43
  • 1
    very cool, both the Ctrl-d and the echo trick worked nicely, thanks! Dec 5, 2015 at 9:03

2 Answers 2

20

This is not the more pager, this is Vim's internal and minimalistic pager which doesn't have search capabilities.

But you can use the :redir command:

:redir @a    redirect output of following commands to register a
:let         list every current option and its value
G<CR>        go straight to the end of the listing and make it disappear
:redir END   stop redirection
:tabnew      open a new buffer in a new window in a new tab page
"ap          put from register a

… then use regular Vim commands.

5
  • oh very cool, thats a great command to know! thanks Dec 5, 2015 at 9:09
  • 8
    slightly simpler: :redir @b|sil let|redir end Dec 5, 2015 at 12:38
  • Even though it is not the more pager, I feel like there is room for a plugin to replace Vim's more pager with less
    – Max Coplan
    Mar 16, 2020 at 19:05
  • 1
    @MaxCoplan you could try this: gist.github.com/romainl/eae0a260ab9c135390c30cd370c20cd7 It's not exactly a pager but I've found it to be pretty useful.
    – romainl
    Mar 18, 2020 at 9:49
  • @romainl thanks
    – Max Coplan
    Mar 18, 2020 at 17:03
22

Vim 8 has a execute() command the allows you to get the output of a command. To see it to the current buffer do:

:put =execute('let')

For Vim 7 you can use capture.vim. It is a plugin that wraps the commands from @romainl's answer and lets you use it as

:Capture let
2
  • thats good to know, thanks. I'll check it out when I upgrade. On vim 7 Im using steve losh's clam plugin to capture large amounts of output into a new buffer. it works well too Dec 1, 2016 at 20:21
  • Both this answer and @romainl's are great for different uses. This one (:put =execute(…)) is what I will use when I want to run a command and get the output in the same buffer. If I want the output in a different buffer, I'll use :redir @a; :let; redir END. This is going to help me finally get my highlighting and syntax annoyances figured out after 20 years! Feb 2, 2020 at 2:59

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.