Author: Max Brunsfeld http://www.github.com/maxbrunsfeld
Yankstack.vim is a lightweight implementation of the Emacs 'kill ring' for Vim. It allows you to yank and delete things without worrying about losing the text that you yanked previously. It effectively turns your default register into a stack, and lets you cycle through the items in the stack after doing a paste.
This plugin is intended to be a simpler alternative to the yankring plugin. It has a fairly complete test suite based on rspec and vimbot.
I recommend loading your plugins with vundle or pathogen.
By default, yankstack adds only 2 key bindings, in normal and visual modes:
meta-p
- cycle backward through your history of yanksmeta-shift-p
- cycle forwards through your history of yanksAfter pasting some text using p
or P
, you can cycle through your
yank history using these commands. Typing either of these keys without pasting first
will do a normal paste (the same as typing p
). This also works in insert mode.
If you're using MacVim, and you want to use
this plugin's default key bindings (or any bindings involving the option
key), you must :set macmeta
. On Linux, you may have issues with the meta key if your terminal is running in 7bit mode.
Instructions for dealing with this can be found on the wiki
You can see the contents of the yank-stack using the :Yanks
command.
Its output is similar to the :registers
command.
Yankstack defines two plugin mappings that you can map to keys of your choosing. The same mappings work in normal and insert modes.
<Plug>yankstack_substitute_older_paste
- cycle backwards through your history of yanks<Plug>yankstack_substitute_newer_paste
- cycle forwards through your history of yanksFor example, if you wanted to define some mappings based on your 'leader' key, you could do this:
nmap <leader>p <Plug>yankstack_substitute_older_paste
nmap <leader>P <Plug>yankstack_substitute_newer_paste
Also, if you want to load yankstack without the default key mappings, just
let g:yankstack_map_keys = 0
in your .vimrc file.
Yankstack works by mapping the yank and paste keys to functions that do some
book-keeping before calling through to the normal yank/paste keys. You may want
to define your own mappings of the yank and paste keys. For example, I like to
map the Y
key to y$
, so that it behaves the same as D
and
C
. The yankstack mappings need to happen before you define any such
mappings of your own. To achieve this, just call yankstack#setup()
in
your vimrc, before defining your mappings:
call yankstack#setup()
nmap Y y$
" other mappings involving y, d, c, etc
You can also prevent certain keys from being remapped by setting the g:yankstack_yank_keys
to the keys of your choosing. For example, if you only want Yankstack to remap y
and d
:
let g:yankstack_yank_keys = ['y', 'd']
I'd enjoy hearing anybody's feedback on yankstack, and welcome any contribution. Check it out on github!
Copyright (c) Max Brunsfeld. Distributed under the same terms as Vim itself. See the vim license.
vim:tw=78:ts=8:ft=help:norl: