Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Found out today that if you press Ctrl-Opt-Cmd-V in Textmate, it produces a cute little "chooser" dialogue in-place that allows you to page through your recent clipboard entries. It looks very similar to how CTRL-P and -N work in VIM, except it shows whole lines instead of simple word objects.

It seems like this would be doable in VIM — it already has a buffer full of entries (the YankRing buffer, for example), and it already has a chooser, but I can't think of where I'd look to start putting these two together. Any ideas?

(I know that YankRing already does this by opening a new window full of buffer content, but I wonder if there's a way to do it without all the window switching/closing/etc)

share|improve this question

2 Answers 2

Vim provides two user-defined insert completion mechanisms: User defined completion and Omni completion. You can read about them here:

:help compl-function
:help compl-omni
:help complete-functions
:help 'completefunc'
:help 'omnifunc'

I've never used these myself, but since you asked for where to start looking, that's it. You may also want to read this section,

:help ins-completion

for an explanation of Vim's various built-in insert-mode completion mechanisms, which may help you avoid writing your own. I didn't see a predefined mechanism for selecting from clipboard entries, however. You can insert from previous deletions with a little work by using :registers to view the available registers and then inserting the contents of the desired register with Ctrl-R followed by the register name. See

:help :register
:help registers
:help i_CTRL-R
share|improve this answer
    
Thanks! Feel like I'm a lot closer now. –  Doug Avery Feb 25 '11 at 15:18
    
The "previous deletions" register is my biggest VIM complaint, because VIM throws everything I delete in there along with things I purposefully yank. Using :reg is pretty inefficient, so I've been using YankRing instead to simulate an emacs-like killring behavior. –  Doug Avery Feb 25 '11 at 15:20

My answer is probably a bit OT but I prefer to have a system-wide clipboard manager as this functionality is useful in many contexts. Here are the ones I'm using with the exact same keyboard shortcut for each:

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.