Can't copy certain gvim text, eg :version or error messages

7

Generally, my copy/paste works just fine in vim.

However, when I type :version, my mouse pointer becomes a symbol like:

no, not allowed

While I can select text, I can't copy it to the clipboard.

Exactly the same behaviour with error output.

How do I disable this "feature"?

Tom Hale

Posted 2015-11-22T13:49:05.077

Reputation: 1 348

Answers

4

In that message output mode, copying with the mouse indeed isn't possible. Only a few paging commands are available there. So, that "feature" doesn't exist yet.

There are several ways to obtain the output. The most generic is via :redir, e.g. into the unnamed register:

:redir @"
:version
:redir END
:put

For a single (last) error message, you can also directly access this via v:errmsg:

:put =v:errmsg

In the terminal, you could also disable Vim's mouse integration via :set mouse=, and then use the terminal's mouse drag to copy the (visible) text.

Ingo Karkat

Posted 2015-11-22T13:49:05.077

Reputation: 19 513

You can make a single command in your vim rc: command! PutMessages redir @" | messages | redir END | put – Chiel ten Brinke – 2016-06-09T07:27:11.743

This doesn't seem to function in NeoVim/VimR, unless I misunderstand how it's supposed to be used? When invoking :PutMessages, the :messages are still just printed in red, not copied. (However, `:let @+=v:errmsg works for me; so I know my clipboard support is functioning!) – ELLIOTTCABLE – 2017-10-10T17:46:47.990

1

If you set the 'clipboard' option to autoselect Vim will automatically attempt to become the owner of the system's copy buffer. This will let you copy text in the situations you describe.

Heptite

Posted 2015-11-22T13:49:05.077

Reputation: 16 267