PostsIntroducing Vim-Ecliptic: A More Natural Clipboard Integration
Posted 09/23/2014

Motivation

View Github Repo

Juggling between vim's local clipboard and the system clipboard can be a headache. The plus register (e.g. "+yy, "+p) hinders workflows that require even minimal clipboard use. The register is buried behind a handful of keystrokes, which are not conveniently placed.

What Happens In Vim Stays In Vim

Ecliptic is for users who find vim's builtin solution (:set clipboard=unamedplus) incompatable with their workflow. When using unamedplus, the system clipboard gets polluted with the text of every yank and delete command. Perpetually binding the clipboard to the unnamed register can be confusing and annoying to users. The unamed register is frequently modified more than the clipboard is used. Therefore, it is my opinion that the unnamed register does more harm than good.

Enter Ecliptic

Ecliptic maps the power of "+ to any keystroke prefix. Out of the box this mapping is the c character (mneumonic for clipboard). By default, vim only uses c an operator command, so many c-letter bindings are unmapped. Ecliptic's standard mappings do not clobber default vim functionality.

Ecliptic Scratch

The command cb represents ecliptic-buffer. This will open a scratch buffer containing contents of the clipboard (+ register).

Each edit to this buffer will replace the clipboard with entirety of the buffer.

cb open ecliptic scratch buffer
\ refresh an opened ecliptic scratch buffer with current clipboard contents

Examples

* cursor position represented by [ ]

<tr>
  <td>
    cursor at start of line:<i>"[H]oney how come you don't move"</i><br>
    clipboard: <i>Babe</i><br>
    unnamed: <i>baz</i>
  </td>
  <td>
    <code>dw cp</code>
  </td>
  <td>
    vim line:<i>"Babe[ ]how come you don't move"</i><br>
    clipboard: <i>Babe</i><br>
    unnamed: <i>Honey</i>
  </td>
</tr>
Before Command Result
buffer:"[A]nd, you ask why I don't live here?"
clipboard: foobar
unnamed: baz
dW cyy vim line:"And, [y]ou ask why I don't live here?"
clipboard: "you ask why I don't live here?"
unnamed: And,

Standard Usage

Yank Proxies

cy{motion} y yank
cyy yy
cY Y
{Visual}cy v_y
{Visual}cY v_Y

Delete Proxies

cd{motion} d
cdd dd
cD D
{Visual}cd v_d
{Visual}cD v_D

Put Proxies

cp p put
cP P
cgp gp
cgP gp
{Visual}cp replace visual selection with clipboard

Customization

By default, Ecliptic sets the prefix to c(a mneumonic for clipboard). This can be changed by setting the g:ecliptic_prefix variable in the .vimrc file.

Here is an exampe remapping the prefix to the - key:

let g:ecliptic_prefix = '-'

Now commands like -yy, and -p will invoke Ecliptic commands.

Installation

+Cliboard Requirement

Ecliptic makes use of the "+ register. Access to this register requires the +clipboard option. Since this option is specified during installation, vim will need to be reinstalled for it to be enabled. Run the following command to check for +clipboard flag on the current version of vim:

$ vim --version | grep +clipboard || echo 'Ecliptic requires +clipboard'

If it does not return 'Ecliptic requires +clipboard', then the plugin will work.

If the flag is missing, then vim needs to be reinstalled. Installation varies system to system. Heres an example of how to do it on Mac OS X with homebrew.

$ brew install macvim --override-system-vim

A google search can provide directions on how to get a proper vim installation on other systems.

Vundle Users

Add the following line to the .vimrc

Bundle "richsoni/vim-ecliptic"

Pathogen Users

$ cd ~/.vim/bundle
$ git clone git://github.com/richsoni/vim-ecliptic.git