Re: how to keep system clipboard in Vim register?

19 views
Skip to first unread message

Enan Ajmain

unread,
Jan 6, 2023, 1:04:20 AM1/6/23
to vim...@googlegroups.com
On Thu, 5 Jan 2023 13:22:09 +0100
Igor Lerinc <igor.l...@gmail.com> wrote:
> I setted up to copy from system clipboard with this in .vimrc
>
> noremap <Leader>y "+y
> noremap <Leader>p "+p

I can't help with your main question (I don't think what you're asking
is possible without creating custom functions), but I wanted to suggest
an alternative way to use system clipboard than mapping. See “:h 'cb'”.

:set clipboard+=unnamed,unnamedplus


--
Enan
3nan....@gmail.com
https://git.sr.ht/~enan/
https://www.github.com/3N4N

Walter Cazzola

unread,
Jan 7, 2023, 6:16:04 AM1/7/23
to vim...@googlegroups.com
On Thu, 5 Jan 2023, Igor Lerinc wrote:

> how to keep system clipboard in Vim register?

> I setted up to copy from system clipboard with this in .vimrc

> noremap <Leader>y "+y
> noremap <Leader>p "+p

> but that interferes with Vim inner registers.
> when i yank, or delete something in vim, (like, i copy something from
> website, so i can put it in file via Vim), i need to delete current line
> and insert what i have in system clipboard.

> but, when i delete something in vim, it stores that text in that same
> unnamed register. so, i need to go back to the app again, to copy what i
> want.
> (or, to first delete in Vim, and then copy from site, and paste in Vim
> (facepalm))

> How i can fix this?

> When Vim replaces that register (unnamed), it is not placed in numbered
> registers at all ! which make my work harder ! it would be simple, as "1 to
> get that register which was pushed. but here, it gets replaced completely.

I'm not sure that this is what you are looking for but if you paste what
coming from another app with "+p or "+[p (note the " is part of the keystroke)
your selection is not overridden by what you delete.

HTH
Walter

--
Reply all
Reply to author
Forward
0 new messages