Re: GVIM replace from clipboard woes!

19 views
Skip to first unread message

Bram Moolenaar

unread,
Dec 27, 2021, 7:30:06 AM12/27/21
to vim...@googlegroups.com, Mike Schleif

Mike Schleif wrote:

> I use VIM on various *NIX platforms.
>
> I use GVIM on various MS Windows hosts.
>
> I often do this:
> 1. Copy a string to the clipboard
> 2. Visual mode select a string
> 3. :s/<type a substring to be replaced>/<Ctrl-v the clipboard string>/g
> 4. Enter - replace all substrings
>
> This works delightfully everywhere - EXCEPT one Windows host!
>
> I'm sure that I've got something in that host's VIMRC; but, what is it?
>
> This has been plaguing me for months ...
>
> Please, advise. Thank you.

Did you check the value of the 'clipboard' option?

--
An actual excerpt from a classified section of a city newspaper:
"Illiterate? Write today for free help!"

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Mike Schleif

unread,
Dec 27, 2021, 6:11:37 PM12/27/21
to Bram Moolenaar, vim...@googlegroups.com
source $VIMRUNTIME/mswin.vim
" Last change: 2017 Oct 28

if has("clipboard")
    " CTRL-X and SHIFT-Del are Cut
    vnoremap <C-X> "+x
    vnoremap <S-Del> "+x

    " CTRL-C and CTRL-Insert are Copy
    vnoremap <C-C> "+y
    vnoremap <C-Insert> "+y

    " CTRL-V and SHIFT-Insert are Paste
    map <C-V> "+gP
    map <S-Insert> "+gP

    cmap <C-V> <C-R>+
    cmap <S-Insert> <C-R>+
endif


NOTE: I created a 2nd post, when this one didn't appear for several hours. In that post, I remembered to describe the undesired behavior:

On that host, Ctrl-v pastes the entire Visual Mode selection - NOT the originally copied string!

Please, advise. Thank you.

~ Mike

Christian Brabandt

unread,
Dec 28, 2021, 3:28:20 AM12/28/21
to vim...@googlegroups.com

On Mo, 27 Dez 2021, Mike Schleif wrote:

> NOTE: I created a 2nd post, when this one didn't appear for several hours. In that post, I remembered to describe the undesired behavior:
>
> On that host, Ctrl-v pastes the entire Visual Mode selection - NOT the originally copied string!
>
> Please, advise. Thank you.

Not sure what exact problem you are facing. Please check (or show) the
following options:

:set guioptions?
:set clipboard?

Also note, you can check what is in your register by using the :register
command. That show the clipboard (+) as well as the various other
internal Vim registers

Best
Christian
--
Wer sich von jeher erlaubt hätte, die Welt so schlecht
anzusehen, wie uns die Widersacher darstellen, der müsste ein
miserables Subjekt geworden sein.
-- Goethe, Maximen und Reflektionen, Nr. 422
Reply all
Reply to author
Forward
0 new messages