Basically, I need advice on how to do the opposite of what is described here:
How to make vim paste from (and copy to) system's clipboard?
I do not want vim to overwrite system clipboard when I delete something within the editor. The usual workflow for me is to select a piece of code (let us call it piece #1) with a mouse, then go to another piece of code (let us call it piece #2), select piece #2 in visual mode in vim, delete it using "c", and paste piece #1 using mouse middle button. With the new behavior, instead of pasting piece #1 I paste back piece #2.
In vim 7.2 I can do that, but in vim 7.4 I can not. I want to use 7.4 due to proper C++11 syntax highlighting but this changed default behavior is killing me.
I think, it has something to do with the "+xterm_clipboard" and/or "+clipboard" features of vim (vim --version), and I need to change them somehow to "-xterm_clipboard" and/or "-clipboard". I tried to recompile vim 7.4 with the option "--with-x=no" but somehow it did not help.
Please, help me to disable copying/pasting in vim to system clipboard by default.
Thank you!
If you're in normal mode, Ctrl-C aborts the current command in progress. Then press u to undo anything that changed before you stopped it.
We can use the “+p and <Ctrl+r>+ in normal and command mode, respectively. However, it might be more convenient if we use the <Ctrl+Shift+v> hotkey since it does the same thing as “+p. Similarly, <Ctrl+Shift+c> will yank the text into the + register to be available for pasting outside of Vim.
When using Vim under Windows, the clipboard can be accessed with the following: In step 4, press Shift+Delete to cut or Ctrl+Insert to copy. In step 6, press Shift+Insert to paste.
To copy text to the system clipboard, use "+y . The " allows you to specify the register, + is the register that represents the system clipboard, and you already know what y does. Alternatively, to tell vim to use the + register as the default register, put set clipboard=unnamedplus in your .
Well, to answer the question in your title, you can just do
:set clipboard=
Which will make vim use it's internal register instead of the system one.
But really, this behavior has nothing to do with the system clipboard. It's more just a general misunderstanding of vim registers.
Vim by default "cuts" rather than "deletes". This means that every delete command (c
and d
) yanks to the unnamed register at the same time. To get around this, just use the black hole register, e.g. use "_c
or "_d
instead of just doing c
or d
.
9. Black hole register "_ *quote_*
When writing to this register, nothing happens. This can be used to delete
text without affecting the normal registers. When reading from this register,
nothing is returned. {not in Vi}
To make this the default behavior for your specific case, you can do
xnoremap c "_d
The 'x' in 'xnoremap' means this mapping applies to visual mode (with v) and select mode (with the mouse)
Related SO link.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With