52

GitHub - machakann/vim-highlightedyank: Make the yanked region apparent!

 6 years ago
source link: https://github.com/machakann/vim-highlightedyank
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

vim-highlightedyank

Make the yanked region apparent!

Usage

If you are using Vim 8.0.1394 (or later version),

there is no need for configuration, as the highlight event is automatically triggered by the TextYankPost event.

If you are using older Vim,

define a keymapping to <Plug>(highlightedyank). Checking the existence of TextYankPost event would be good.

if !exists('##TextYankPost')
  nmap y <Plug>(highlightedyank)
  xmap y <Plug>(highlightedyank)
  omap y <Plug>(highlightedyank)
endif

If you are using Neovim,

you don't need this plugin. Check out here.

Optimizing highlight duration

If you want to optimize highlight duration, use g:highlightedyank_highlight_duration or b:highlightedyank_highlight_duration. Assign a number of time in milliseconds.

let g:highlightedyank_highlight_duration = 1000

A negative number makes the highlight persistent.

let g:highlightedyank_highlight_duration = -1

When a new text is yanked or user starts editing, the old highlighting would be deleted.

Highlight coloring

If the highlight is not visible for some reason, you can redefine the HighlightedyankRegion highlight group like:

highlight HighlightedyankRegion cterm=reverse gui=reverse

Note that the line should be located after :colorscheme command execution in your vimrc.

Suppress highlight in visual mode

The highlight may not be needed or even annoying in visual mode.

let g:highlightedyank_highlight_in_visual = 0

Inspired by

vim-highlightedyank

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK