vim-ecliptic
vim-ecliptic copied to clipboard
Ecliptic.vim: Amicable Clipboard Integration
Ecliptic.vim: Amicable Clipboard Integration
#Motivation
Juggling between vim's local clipboard and the system clipboard is a headache.
The plus register (e.g. "+yy, "+p) hinders workflows that require even minimal use of the clipboard.
It is a significant amount of keystrokes, and the keys are not in inconvenient places.
What Happens In Vim Stays In Vim
Ecliptic is for those who find vim's builtin solution (:set clipboard=unnamedplus) inconvenient.
When using unnamedplus 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 for some.
The unnamed register is frequently modified more than the clipboard is used.
Enter Ecliptic
Ecliptic maps the power of "+ to a more natural interface.
All of its mapping start with the c prefix (mnemonic for clipboard).
By default c is just an operator, so many c-letter bindings are unmapped.
Ecliptic's mappings do not clobber default vim functionality.
#Usage
##Yank Proxies
cy{motion} |
y yank |
cyy |
yy |
cY |
Y |
{Visual}cy |
v_y |
{Visual}cY |
v_Y |
c% |
expand("%:p") {copies the current filename} |
##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 |
Custom Prefix
By default Ecliptic sets the prefix to c as a mnemonic for clipboard.
This can be changed by setting the g:ecliptic_prefix variable in your .vimrc.
Here is an example remapping the prefix to the - key:
let g:ecliptic_prefix = '-'
Now commands like -yy, and -p will invoke Ecliptic commands.
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 [ ]
| 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, |
Installation
+Clipboard Requirement
Ecliptic makes use of the "+ register, which gets enabled during installation.
The plugin will not work without the +clipboard option which exposes the "+ register.
Run the following command to check for +clipboard flag:
$ vim --version | grep +clipboard || echo 'Ecliptic requires +clipboard'
If it does not return 'Ecliptic requires +clipboard', then you are good to go.
If you are missing the flag, then you need to reinstall vim. 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 help you get a proper vim installation on other systems.
Vundle Users
Add the following line to your .vimrc
Bundle "richsoni/vim-ecliptic"
Pathogen Users
$ cd ~/.vim/bundle
$ git clone git://github.com/richsoni/vim-ecliptic.git