Ⅰ. 插件描述
Clipboard tools for vimⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'mg979/vim-yanktools'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'mg979/vim-yanktools'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'mg979/vim-yanktools'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/mg979/vim-yanktools
Ⅳ. 文档说明
### Yanktools
<!-- vim-markdown-toc GFM -->
<!-- vim-markdown-toc -->
Installation
Use vim-plug or any other plugin
manager.
With vim-plug:
Plug 'mg979/vim-yanktools'
Features list
- __Yank Stack__: yanks and deletions are stored in a list, that can be cycled
at cursor position, back and forth, with a specific keybinding, swapping
elements of the stack, and keeping properties of the last paste command
(autoformat, paste before, etc).
- __Manual and Recording modes__: stacks will be filled with specific mappings,
or automatically at every yank/delete operation, respectively. Can be
toggled.
- __Preservation of unnamed register__: c, C, x, X, Del, visual paste
- __Swap-&-paste__: cycle among stack elements, or show them in popup/preview
window. - __Replace operator__: replace text objects with register. Repeatable.
- __Duplicate operator__: without altering registers. Repeatable.
- __Zeta stack__: a disposable yank stack, from which items are taken from the
back, and pasting them removes them from the stack as well. You can populate
the stack both by yanking and deleting.
- __Autoindent__: you can toggle it, or use mappings to perform a single
indented paste. - __Interactive paste__: with preview window or fzf-vim
- __Convert yank type__: convert selected register to/from blockwise.
- Optional persistance
Introduction
Yanktools is a plugin inspired by vim-yankstack and vim-easyclip.
The main concept is to have a dedicated stack, where yanks and deletions can
be stored and later accessed, so to have a "clipboard history" in vim.
The main difference between this and other plugins of this kind, is that
saving yanks and deletions in the stack isn't an automatic process, at least by
default.
Adding a new item (yank or deletion) to the yank stack is the result of
either:
- a yank/deletion performed with a specific mapping
- saving a register directly in the stack
- enabling the _recording mode_, that allows automatic addition to the stack
Usage
A main key should be defined, and this key will used for both saving into the
stack, and for the replace operator. I use the 's' key.
let g:yanktools_main_key = 's' " or '<c-s>', 'S', 'Z'...
Read the documentation for more details.
Defined operators and their default behaviour (assuming 's' as main key):
| mapping | name | function |
|---|---|---|
| sy | yank & save | add yanked text to the yank stack |
| sd | delete & save | add deleted text to the yank stack |
| s | replace | replace text object with register |
| yd | duplicate | duplicate text object |
Visual mode mappings:
| mapping | name |
|---|---|
| sy | yank & save |
| sd | delete & save |
| Del | preserve unnamed register |
| M-d | duplicate |
Other normal mode mappings:
| mapping | name |
|---|---|
| ]p | paste after the cursor and autoindent |
| [p | paste before the cursor and autoindent |
| M-p | cycle the stack (+1) and paste |
| M-P | cycle the stack (-1) and paste |
| ]y | cycle the stack (+1) and preview in popup |
| [y | cycle the stack (-1) and preview in popup |
Zeta mode:
| Normal | Visual | |
|---|---|---|
| yz | yank | ZY |
| dz | delete | ZD |
| zp | paste | ZP |
Example settings:
" make 'S' replace until the end of the line
let g:yanktools_main_key = 's'
nmap S s$
nnoremap Y y$
Full documentation with :help yanktools.txt
Pictures
Swapping:

Interactive paste with fzf:

Preview with popup (vim 8.1 or neovim 0.4)

Related projects
vim-easyclip
vim-yankstack
nvim-miniyank
vim-yank-queue
License
License: same terms as Vim itself