Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable ''Press ENTER or type command to continue" when I execute `write !xsel -b`

Tags:

vim

pipe

My vim doesn't shipped with +clipboard, so I could not use like "+y commands to copy and paste with clipboard.

I want to map to copy the text to clipboard, which is

vnoremap <C-c><C-c> :write !xsel -b<CR>

however, it will shows "Press ENTER or type command to continue", which is boring. How should I disable the message?

like image 476
Run Avatar asked Oct 20 '25 11:10

Run


1 Answers

You can use the :silent command to suppress that output.

There's a small issue in doing that in a vnoremap, since that adds a '<,'> range to your command, but that needs to be a range for write and not silent, so use <c-u> to delete that added range at the start and then add it explicitly after the silent.

Putting it all together:

vnoremap <C-c><C-c> :<c-u>silent '<,'>write !xsel -b<cr>

Another possible solution is to add an extra <cr> to the end of the original mapping, to go past the "Press ENTER" prompt:

vnoremap <C-c><C-c> :write !xsel -b<cr><cr>
like image 65
filbranden Avatar answered Oct 23 '25 08:10

filbranden



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!