machakann / vim-highlightedyank

Make the yanked region apparent!
844 stars 22 forks source link

Vim: Highlight nnoremap Y y$ (from :h Y) #25

Closed kiryph closed 6 years ago

kiryph commented 6 years ago

What do I have to define in my vimrc to enable highlighting for nnoremap Y y$ as suggested under :h Y?

:ver
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Nov  4 2017 04:39:11)
macOS version
Included patches: 1-1257
Compiled by travis@Traviss-Mac-793.local
Huge version with MacVim GUI.
kiryph commented 6 years ago

Following definition works

map Y <Plug>(highlightedyank)$

Can you confirmm that this is the way to go?

BTW, there is also the plugin https://github.com/haya14busa/vim-operator-flashy

machakann commented 6 years ago

Yes, this is the best way, I think. I would better to add to README and/or doc. In fact, I just write like this in my vimrc since I'm lazy.

nmap Y y$

This is not strict/explicit but works even without highlightedyank.

P.S. Yes, operator-flashy is a great plugin! In fact, I have employed it. Generally operator-flashy would be a cleaner implementation. However, it is strange to me that it is unintentionally repeated by . command even without y in cpoption. In Vim, highlightedyank has some dirty hack to avoid this (issue #19 is caused by this). TextYankPost autocommand event in neovim solves this problem, so I hope vim also had it.

kiryph commented 6 years ago

Thanks for the information.

There is now a pending pull request for vim8 to add TextYankPost: https://github.com/vim/vim/pull/2333.

machakann commented 6 years ago

Thanks! I can't wait!