13

vim 如何复制 message 命令的输出到系统剪切板

 2 years ago
source link: https://ttys3.dev/post/how-to-copy-message-command-output-to-system-clipboard-in-vim/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

vim 如何复制 message 命令的输出到系统剪切板

2021-03-21

:: 荒野無燈

:: Mod 2021-03-21(383c481)

March 21, 2021

vim 要支持复制到系统剪切板,首先要确保系统安装了 xclip 之类的剪切板工具。

主要的使用场景是复制一些错误信息。

要复制 :message 的输出, 解决办法就是将输出重定向剪切板。

the clipboard register (@+) or primary register (@*)

:redir @+
:3message
:redir END

See :help :redir:help :message

当然,每次都敲这么多命令也是挺麻烦的,直接定义一个名为 CpMsg command 好了:

command! -bang CpMsg redir @+ | 99message | redir END

https://stackoverflow.com/questions/41663646/how-to-copy-to-clipboard-3-last-lines-from-messages/41664344#41664344

https://superuser.com/questions/167352/how-do-i-copy-command-output-in-vim/171105#171105


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK