1

In some editing senario, I want to do a series of deleting, and do not want to clutter with the system clipboard, which I use an external program to management the history of it.

The question is, how to make dd act like "_dd?

Maybe set clipboard=some-value then restore the old value.

On my machine, set clipboard? outputs clipboard=unnamed.

2
  • 2
    just remove unnamed from clipboard
    – Mass
    Commented Jun 7, 2018 at 4:24
  • @Mass but that would use the " register. OP wants the blackhole register. Isn't it?
    – 3N4N
    Commented Jun 7, 2018 at 4:49

1 Answer 1

1

I don't think clipboard can be set to anything other than unnamed or unnamedplus. Because, clipboard was introduced for associating vim's register with operating system's clipboard. But I'm not sure. Maybe someone can help me out.

My suggestion would be to use a simple mapping:

nnoremap d "_d

and when you don't need it anymore just do

unmap d

This should get you started for now. I'll try and come up with a vimscript function to toggle the situation before you become bored with this solution. Afterwards I'll edit this answer.

Edit: I came up with this hideous function. I don't know if it should be used or if it will hamper any regular use cases. But it works for now. Maybe someone will help me out. Here it is:

nnoremap <silent> <leader>tb :call ToggleBlackHole()<cr>
function! ToggleBlackHole() abort
  if maparg("d", "n") ==# ''
    nnoremap d "_d
  else
    unmap d
  endif
endfunction

So, OP should be able to use <leader>tb to toggle blackhole register and unnamed register for deleting.

1
  • How stupid was I.
    – qeatzy
    Commented Jun 7, 2018 at 12:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.