ojroques / vim-oscyank

A Vim plugin to copy text through SSH with OSC52
BSD 2-Clause "Simplified" License
630 stars 39 forks source link

Update README.md register copying #18

Closed zdrazil closed 3 years ago

zdrazil commented 3 years ago

Using https://github.com/machakann/vim-highlightedyank together with this plugin by using the following in .vimrc (notice that autocmd part is the same as in README.md:

call plug#begin('~/.vim/plugged')

Plug 'ojroques/vim-oscyank'
Plug 'machakann/vim-highlightedyank'

call plug#end()

autocmd TextYankPost * if v:event.operator is 'y' && v:event.regname is '+' | OSCYankReg + | endif

breaks vim-highlightedyank functionality. If you press yy, the yank is no longer highlighted.

And if you use the first example from the README.md:

autocmd TextYankPost * if v:event.operator is 'y' && v:event.regname is '' | OSCYankReg " | endif

the highlight no longer works when you press "+yy.

Looks like it could be a similar issue as described here: https://vi.stackexchange.com/questions/13454/endif-treated-as-part-of-command-in-autocmd. The endif gets swallowed.

Found two possible fixes:

  1. Start using -bar option with the command - :h command-bar
  2. Wrap the command inside a string and execute with execute .

I've went with the second option, because I'm not sure what the first option could break and if it would be backwards compatible.

ojroques commented 3 years ago

Looks good to me. Thank you very much :)

zdrazil commented 3 years ago

Happy to help :)