kana / vim-fakeclip

Vim plugin: Provide pseudo "clipboard" registers
http://www.vim.org/scripts/script.php?script_id=2098
180 stars 36 forks source link

set operatorfunc=fakeclip#clipboard_delete not working as expected when mapped to keys without a modifer #9

Open Forethinker opened 11 years ago

Forethinker commented 11 years ago

Instead of using "+ or "* modifiers to copy into the special registers, I wanted my normal commands (without modifiers) to use special registers.

My remapping works fine for yank, but not for delete. If I do 4dd, it only deletes one line and pastes one line into the register (consequently xclip) and if I do 4D vim once again deletes the line, but then replaces it with an empty line. My remapping also modified the aforementioned operations with modifiers. (e.g. "*4dd or "+4dd)

Other than that, my remapping works fine with other delete operations in visual mode or any operation that ends with single d in normal mode.

Below is what I pasted in .vimrc

silent! nmap  y  <Plug>(fakeclip-y)
silent! nmap  Y  <Plug>(fakeclip-Y)
silent! nmap  yy  <Plug>(fakeclip-Y)
silent! vmap  y  <Plug>(fakeclip-y)
silent! vmap  Y  <Plug>(fakeclip-Y)

silent! nmap  p  <Plug>(fakeclip-p)
silent! nmap  P  <Plug>(fakeclip-P)
silent! nmap  gp  <Plug>(fakeclip-gp)
silent! nmap  gP  <Plug>(fakeclip-gP)
silent! nmap  ]p  <Plug>(fakeclip-]p)
silent! nmap  ]P  <Plug>(fakeclip-]P)
silent! nmap  [p  <Plug>(fakeclip-[p)
silent! nmap  [P  <Plug>(fakeclip-[P)
silent! vmap  p  <Plug>(fakeclip-p)
silent! vmap  P  <Plug>(fakeclip-P)
silent! vmap  gp  <Plug>(fakeclip-gp)
silent! vmap  gP  <Plug>(fakeclip-gP)
silent! vmap  ]p  <Plug>(fakeclip-]p)
silent! vmap  ]P  <Plug>(fakeclip-]P)
silent! vmap  [p  <Plug>(fakeclip-[p)
silent! vmap  [P  <Plug>(fakeclip-[P)

silent! map!  <C-r>  <Plug>(fakeclip-insert)
silent! map!  <C-r><C-r>  <Plug>(fakeclip-insert-r)
silent! map!  <C-r><C-o>  <Plug>(fakeclip-insert-o)
silent! imap  <C-r><C-p>  <Plug>(fakeclip-insert-p)

###  " trouble makers below                                                                                
silent! nmap  d  <Plug>(fakeclip-d)
silent! vmap  d  <Plug>(fakeclip-d)
silent! nmap  dd  <Plug>(fakeclip-dd)
silent! nmap  D  <Plug>(fakeclip-D)
silent! vmap  D  <Plug>(fakeclip-D)

Would you happen to know why this is happening? I am using vim 7.3, Crunchbang Waldorf (Debian variant) Thanks for the awesome plug-in!

kana commented 11 years ago

Thank you for the report. I've never thought such usage. It seems not to be obvious why it doesn't work properly. I'll look into the problem later.

kana commented 11 years ago

I've discovered that fakeclip doesn't handle <count> correctly in some cases.

<count> is ignored in the following cases:

I'll fix the problem later.

krader1961 commented 10 years ago

I noticed the same problem. It also appears to be impossible to create maps that provide the equivalent of "set clipboard=unnamedplus". I'm going to explore the possibility of creating an auto-command that allows intercepting access to registers.