How can I get a navigable (editable?) buffer with vim's `messages`?

Solution 1:

The answer by Heptite is a good way to do this using built-ins. If you're okay with using a plugin, my bufferize plugin automates the process a bit. Lets you just do:

:Bufferize messages

In order to get a preview buffer with the contents of that command's output.

As a side note, I'm surprised the :messages output is not selectable. I guess maybe you're using Vim with a GUI? With terminal Vim, you can select, and then middle-click-paste the content.

Solution 2:

Try this:

:redir > messages.txt
:messages
:redir END
:e messages.txt

You can suppress output to the display while still capturing the messages output by changing :messages to :silent messages.

Solution 3:

Try this:

:put = execute('messages')