• Stars
    star
    405
  • Rank 106,656 (Top 3 %)
  • Language
    Vim Script
  • Created about 14 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Maintains a history of previous yanks, changes and deletes
This is a mirror of http://www.vim.org/scripts/script.php?script_id=1234

Vim already maintains a list of numbered registers containing the last 9 deletes.  These previous deletes can be referenced using [register]p, so "1p will paste the last delete, "2p the 2nd last delete.  For more information see |quote_number|.

Vim does not provide any mechanism to reference previous yanked, deleted or changed text.  In Emacs this feature is called the "kill ring".

The YankRing plugin allows the user to configure the number of yanked, deleted and changed text.  A split window can be used to choose which element(s) from the yankring you wish to paste.  Alternately after text has been pasted (using p), it can be replaced with a previous value from the yankring with a single key stroke.

The captured text is stored in a file (location configurable) and is instantly available (also configurable) to any other instance of Vim also running on the same machine.  This can especially be useful on *nix machines when you are sshed in running Vim in multiple terminals.

Storing the capture text in a file allows the text to be shared easily between multiple instances of Vim running in X, Windows, SSH or Screen.

A tutorial is included to take you through the various features of the plugin.  After you have installed the plugin just run:
     :h yankring.txt
     :h yankring-tutorial

The yankring can be interacted with in two ways:  a GUI or via maps.

The yankring supports all of Vim motions and text-objects.  There are very few new keystrokes the user must learn.   One keystroke to open the yankring to choose which item to paste is all that is required.  It has been designed work seamlessly with Vim

All the mappings and behaviours are configurable via global variables you can optionally specify in your vimrc.

The plugin can be toggled on and off, and supports:
    Ranges
    Registers
    Counts
    All visual modes (characterwise, linewise and blockwise)
    All motions
    All text-objects

Examples:
    yy - Adds the current line to the yankring.
    dd - Adds the current line to the yankring and deletes it.
   5yw - Adds 5 words to the yankring.
  "ade - Deletes the word, and puts it into both the yankring and the "a register.
    cw - Changes the word and stores the previous value in the yankring.
10"zyy - Places 10 lines into both the yankring and the "z register.
 :1,4YRYankRange   - Similar to 1,4y
 :3,$YRDeleteRange  - Similar to 3,$d

If you wish to paste previous values from the yankring and do not want to use the GUI, there are only two additional maps you must learn (these are configurable via your vimrc if needed).  The purpose of the yankring is to gain access to previously yanked (or deleted) elements.  The YRReplace command will replace the previously pasted text with a different entry from the yankring.  By default, I choose <C-P> (P for previous) to replace the text last pasted while moving backwards through your previous text from the yankring and <C-N> (N for next) to replace the previous paste while moving forward through the yankring.

A separate buffer window to allow you to easily interact with the contents of the yankring.  The window is similar to many other plugins: TagList, SelectBuf and so on.  You can use the mouse or standard Vim keys (p, gp, P, ...).  Visual mode is used to support counts, pasting multiple times and reversing the order of pasted elements.

The GUI significantly simplifies your interaction with the yankring for basic functions.  But often it useful to take advantage of the more powerful features of the yankring.

Here is a small section from the tutorial (using maps) so you have some idea of how you interact with the plugin gaining access to previous yanks.  Using the GUI for basic operations is self explanatory.

:h yankring-tutorial

---- Partial Tutorial ----
To understand how to use the yankring, the following example should demonstrate the various features.

Assume we have this buffer: 
        one
        two
        three
        four
        five

Now yank (yy) each line separately starting at line 1.  Display the
contents of the yankring. 
        :YRShow  
            --- YankRing ---
            Elem  Content
            5     five^@
            4     four^@
            3     three^@
            2     two^@
            1     one^@
Since we yanked the text starting at line 1 and finishing at line 5, the most current yankring element is the last one, the contents of line 5.  
"five^@" is displayed, the "^@" is a newline character (since we issued a "yy").

Now, go to the end of the file and press p.  The resulting buffer appears as: 
        one
        two
        three
        four
        five
        five
Now press <C-P> to move backwards through the yankring, this results in: 
        one
        two
        three
        four
        five
        four
Now press 2<C-P>.  This would be the same as pressing <C-P> two times in a row.  This results in: 
        one
        two
        three
        four
        five
        two
Now press <C-N> to move forwards through the yankring, this results in: 
        one
        two
        three
        four
        five
        three

You can create a map to display a buffer displaying the yankring's contents:
    nnoremap <silent> <F11> :YRShow<CR>

YRShow creates a new split buffer (you can configure where it should be and it's size)
        :YRShow  
            AutoClose=1;Cmds:<enter>,[g]p,[p]P,d,r,a,u,q,<space>;Help=?
            --- YankRing ---
            Elem  Content
            3     three^@
            2     two^@
            1     one^@
            5     five^@
            4     four^@
You can simply hit "p", <enter>, double click on an item and it will be pasted into your document.  The window will automatically close (by default) after you have made a choice.  The element will be pasted into the correct buffer if you have multiple split windows.

You can paste multiple items using visual mode.
You can also remove items from the yankring.

---- Partial Tutorial ----

Concentrating on the last line of the buffer you could see how we were able to replace our pasted text with lines yanked previously.  This is a feature Vim only has for deletes, and is limited to 9.  This plugin enables the same features for both yanks, deletes and changes, the size of the history is configurable.




More Repositories

1

taglist.vim

Source code browser (supports C/C++, java, perl, python, tcl, sql, php, etc)
Vim Script
650
star
2

dbext.vim

Provides database access to many dbms (Oracle, Sybase, Microsoft, MySQL, DBI,..)
Vim Script
417
star
3

a.vim

Alternate Files quickly (.c --> .h etc)
Vim Script
302
star
4

DrawIt

Ascii drawing plugin: lines, ellipses, arrows, fills, and more!
Vim Script
293
star
5

ReplaceWithRegister

Replace text with the contents of a register.
Vim Script
291
star
6

Conque-GDB

GDB command line interface and terminal emulator in (G)Vim.
Python
275
star
7

AutoComplPop

Automatically opens popup menu for completions
Vim Script
263
star
8

FuzzyFinder

buffer/file/command/tag/etc explorer with fuzzy matching
Vim Script
258
star
9

Conque-Shell

Run interactive commands inside a Vim buffer
Vim Script
248
star
10

vim-auto-save

Automatically save changes to disk
Vim Script
225
star
11

vimwiki

Personal Wiki for Vim
Vim Script
195
star
12

ZoomWin

Zoom in/out of windows (toggle between one window and multi-window)
Vim Script
182
star
13

VimClojure

A filetype, syntax and indent plugin for Clojure
Vim Script
179
star
14

paredit.vim

Paredit Mode: Structured Editing of Lisp S-expressions
Vim Script
177
star
15

DoxygenToolkit.vim

Simplify Doxygen documentation in C, C++, Python.
Vim Script
162
star
16

c.vim

C/C++ IDE -- Write and run programs. Insert statements, idioms, comments etc.
Vim Script
152
star
17

mru.vim

Plugin to manage Most Recently Used (MRU) files
Vim Script
149
star
18

matchit.zip

extended % matching for HTML, LaTeX, and many other languages
Vim Script
148
star
19

argtextobj.vim

Text-object like motion for arguments
Vim Script
138
star
20

Align

Help folks to align text, eqns, declarations, tables, etc
Vim Script
132
star
21

UltiSnips

The ultimate snippet solution for python enabled Vim.
Python
129
star
22

Vim-R-plugin

Plugin to work with R
Vim Script
126
star
23

slimv.vim

SLIME-like Lisp and Clojure REPL inside Vim with Profiling, Hyperspec, Paredit
Common Lisp
119
star
24

bufexplorer.zip

Buffer Explorer / Browser
Vim Script
111
star
25

TaskList.vim

Eclipse like task list
Vim Script
107
star
26

VimIM

Vim Input Method -- Vim δΈ­ζ–‡θΎ“ε…₯法
Vim Script
103
star
27

VOoM

Vim Outliner of Markers -- two-pane outliner and related utilities
Python
98
star
28

SQLUtilities

SQL utilities - Formatting, generate - columns lists, procedures for databases
Vim Script
91
star
29

bash-support.vim

BASH IDE -- Write and run BASH-scripts using menus and hotkeys.
Vim Script
90
star
30

netrw.vim

Network oriented reading, writing, and browsing (keywords: netrw ftp scp)
Vim Script
90
star
31

OmniCppComplete

C/C++ omni-completion with ctags database
Vim Script
89
star
32

LanguageTool

Grammar checker for English, French, German (etc.) in Vim
Vim Script
88
star
33

Pydiction

Tab-complete your Python code
Python
87
star
34

TwitVim

Twitter client for Vim
Vim Script
86
star
35

xoria256.vim

Finely tuned soft gamma, 256 colors, dark background, gvim == vim
Vim Script
84
star
36

indentpython.vim

An alternative indentation script for python
Vim Script
82
star
37

utl.vim

Univeral Text Linking - Execute URLs, footnotes, open emails, organize ideas
Vim Script
80
star
38

fcitx.vim

keep and restore fcitx state when leaving/re-entering insert mode
Vim Script
79
star
39

peaksea

Refined color, contains both gui and cterm256 for dark and light background
Vim Script
77
star
40

SyntaxRange

Define a different filetype syntax on regions of a buffer.
Vim Script
76
star
41

L9

Vim-script library
Vim Script
75
star
42

AnsiEsc.vim

ansi escape sequences concealed, but highlighted as specified (conceal)
Vim Script
72
star
43

LargeFile

Edit large files quickly (keywords: large huge speed)
Vim Script
72
star
44

JavaScript-Indent

Javascript indenter (HTML indent is included)
Vim Script
69
star
45

tComment

An extensible & universal comment plugin that also handles embedded filetypes
Vim Script
68
star
46

The-NERD-tree

A tree explorer plugin for navigating the filesystem
Vim Script
66
star
47

nginx.vim

initial version
Vim Script
65
star
48

camelcasemotion

Motion through CamelCaseWords and underscore_notation.
Vim Script
64
star
49

ShowMarks

Visually shows the location of marks.
Vim Script
64
star
50

closetag.vim

Functions and mappings to close open HTML/XML tags
Vim Script
64
star
51

BufOnly.vim

Delete all the buffers except the current/named buffer
Vim Script
63
star
52

bufkill.vim

Unload/delete/wipe a buffer, keep its window(s), display last accessed buffer(s)
Vim Script
62
star
53

vcscommand.vim

CVS/SVN/SVK/git/hg/bzr integration plugin
Vim Script
61
star
54

Auto-Pairs

Insert or delete brackets, parens, quotes in pair.
Vim Script
61
star
55

AutoClose

Inserts matching bracket, paren, brace or quote
Vim Script
61
star
56

Gundo

Visualize your undo tree.
Python
60
star
57

grep.vim

Grep search tools integration with Vim
Vim Script
56
star
58

javacomplete

Omni Completion for JAVA
Vim Script
56
star
59

SearchComplete

Tab completion of words inside of a search ('/')
Vim Script
55
star
60

VisIncr

Produce increasing/decreasing columns of numbers, dates, or daynames
Vim Script
55
star
61

EasyGrep

Fast and Easy Find and Replace Across Multiple Files
Vim Script
53
star
62

pep8

Check your python source files with PEP8
Vim Script
52
star
63

wombat256.vim

Wombat for 256 color xterms
Vim Script
48
star
64

sessionman.vim

Vim session manager
Vim Script
47
star
65

cscope.vim

create cscope database and connect to existing proper database automatically.
Vim Script
47
star
66

restore_view.vim

A plugin for automatically restoring file's cursor position and folding
Vim Script
46
star
67

Mark--Karkat

Highlight several words in different colors simultaneously. (#1238 continued)
Vim Script
46
star
68

loremipsum

A dummy text generator
Vim Script
45
star
69

ScrollColors

Colorsheme Scroller, Chooser, and Browser
Vim Script
45
star
70

gtags.vim

Integrates GNU GLOBAL source code tag system with VIM.
Vim Script
42
star
71

perl-support.vim

Perl IDE -- Write and run Perl-scripts using menus and hotkeys.
Vim Script
42
star
72

google.vim

Indent file for Google C++ Coding Style
Vim Script
41
star
73

winmanager

A windows style IDE for Vim 6.0
Vim Script
41
star
74

gitignore

Set 'wildignore' from ./.gitignore
Vim Script
40
star
75

sudo.vim

Allows one to edit a file with prevledges from an unprivledged session.
Vim Script
40
star
76

HTML-AutoCloseTag

Automatically closes HTML tags once you finish typing them.
Vim Script
39
star
77

greplace.vim

Replace a pattern across multiple files interactively
Vim Script
38
star
78

CSApprox

Make gvim-only colorschemes work transparently in terminal vim
Vim Script
38
star
79

phpfolding.vim

Automatic folding of PHP functions, classes,.. (also folds related PhpDoc)
Vim Script
38
star
80

SyntaxComplete

OMNI Completion based on the current syntax highlights
Vim Script
37
star
81

vis

Extended Visual Mode Commands, Substitutes, and Searches
Vim Script
36
star
82

snipMate

TextMate-style snippets for Vim
Vim Script
36
star
83

workflowish

ToDo manager plugin inspired by workflowy.com
Vim Script
34
star
84

VimRepress

Plugin for managing wordpress blog from Vim.
Vim Script
34
star
85

Lucius

Dark and light color scheme (GUI and 256 color terminal)
Vim Script
34
star
86

SQLComplete.vim

SQLComplete is a SQL code completion system using the omnifunc framework
Vim Script
34
star
87

Wombat

Dark gray color scheme sharing some similarities with Desert
Vim Script
33
star
88

DirDiff.vim

A plugin to diff and merge two directories recursively.
Vim Script
33
star
89

AutoTag

Updates entries in a tags file automatically when saving
Vim Script
33
star
90

TagHighlight

Extra highlighting of typedefs, enumerations etc (based on ctags)
Vim Script
32
star
91

Gist.vim

vimscript for gist
Vim Script
32
star
92

jsbeautify

a javascript source code formatter
Vim Script
32
star
93

The-NERD-Commenter

A plugin that allows for easy commenting of code for many filetypes.
Vim Script
32
star
94

marvim

Macro Persistent Storage and Shareable Repository for VIM
Vim Script
32
star
95

Python-mode-klen

python mode
Python
31
star
96

scratch.vim

Plugin to create and use a scratch Vim buffer
Vim Script
31
star
97

Emmet.vim

vim plugins for HTML and CSS hi-speed coding.
Vim Script
29
star
98

IndexedSearch

shows 'Nth match out of M' at every search (index of match+total # matches)
Vim Script
29
star
99

errormarker.vim

Highlights and sets error markers for lines with compile errors
Vim Script
29
star
100

TeTrIs.vim

A tetris game in pure vim
Vim Script
29
star