Author Topic: Avoiding having vim deleted text copied to the clipboard  (Read 2611 times)

Ian P

  • Community Member
  • Posts: 59
  • Hero Points: 2
Avoiding having vim deleted text copied to the clipboard
« on: August 20, 2007, 06:49:05 pm »
Hi,

I've recently replaced CodeWright, which I've been using as my "vi-mode" editor for the last 10 years or so, with SlickEdit, which I use in vim mode. So far I'm very impressed. There are one or two minor features that I preferred in CodeWright, but generally that's more than made up for by many other things that are better in SlickEdit.

But one thing that I do hate in SlickEdit is that any text that I delete via vim commands gets copied to the clipboard, replacing whatever's in there. Something that I find myself doing quite regularly is to replace some text in one file with something from another, so I go to the 2nd file and copy the text to the clipboard, go back to the 1st file and type a vim command (e.g. something like "dw" or "dd") to delete the text that I want to replace, and then try to paste in the text that I'd copied. But all that does is to paste the deleted text back in, so I then have to swear a bit and start over.

Text that is deleted via the Edit -> Delete menu does not get copied to the clipboard, so why do so with text that is deleted via a vim command?

So, my question: is there some way to turn off that feature so that text deleted via a vim command does not get copied to the clipboard?

Brandon Hamm

  • Community Member
  • Posts: 30
  • Hero Points: 1
Re: Avoiding having vim deleted text copied to the clipboard
« Reply #1 on: August 20, 2007, 07:54:47 pm »
I fought with this for a bit when I had first started using SE as well.  What I've trained myself to do is instead of executing a 'vi' command like "dw", I'll use the VIM visual mode command to select the word, "vw", then do a "p" to put the text I copied to the clipboard from the other file.

Not really a fix...but after a couple of days, it stopped bothering me.

Brandon

Ryan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 987
  • Hero Points: 77
Re: Avoiding having vim deleted text copied to the clipboard
« Reply #2 on: August 20, 2007, 08:02:02 pm »
Quote
Text that is deleted via the Edit -> Delete menu does not get copied to the clipboard, so why do so with text that is deleted via a vim command?

Well, because that's how Vim behaves  ;)

Quote
So, my question: is there some way to turn off that feature so that text deleted via a vim command does not get copied to the clipboard?

There is not currently an option to not copy the deleted text to the clipboard for Vim commands :(.  You can try using the standard paste command (which in Vim emulation should be bound to Shift+Insert by default).  Vim uses it's own special clipboard, and if the text which you actually want to paste was copied to the standard clipboard, this should work.

- Ryan

Ian P

  • Community Member
  • Posts: 59
  • Hero Points: 2
Re: Avoiding having vim deleted text copied to the clipboard
« Reply #3 on: August 20, 2007, 11:32:26 pm »
Well, because that's how Vim behaves  ;)

Not really. When used with a desktop like GNOME that has the concept of a shared global clipboard, using a delete command in vim does not change anything in the desktop's shared clipboard.

But I guess that using SE's multiple clipboards does give me what I want, if I remember to do it. However, on a first try it doesn't seem to be working correctly. Starting with something in the clipboard that I want to paste in place of a word:

1. I use the vim "dw" command to delete the word.
2. I right-click the location and select "List clipboards" (or press CTRL-Shift-V).
3. The dialog opens up saying "Select the text to paste". I select clipboard 2 which contains the text that I want and click OK. But it pastes in the content of clipboard 1 which is the text that I just deleted. This would seem to be a bug - is it?

It does work properly if I do steps 1 and 2 as above and then go through these additional steps:

3. The dialog opens up saying "select the text to paste". I select clipboard 2 which contains the text that I want and click View.
4. On the View Clipboard dialog I select Copy and the text that I want is copied to from clipboard 2 to clipboard 1.
5. Now I click OK and the text that I want is pasted in.
« Last Edit: August 20, 2007, 11:35:16 pm by Ian P »