• Stars
    star
    345
  • Rank 122,750 (Top 3 %)
  • Language
    Vim Script
  • License
    MIT License
  • Created over 10 years ago
  • Updated 8 months ago

Reviews

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

Repository Details

Vim plugin for copying to the system clipboard with text-objects and motions

System Copy

System copy provides vim mappings for copying / pasting text to the os specific clipboard. Most people will be happy just setting their Vim clipboard to the system clipboard, but I find that doing so pollutes my clipboard history. Instead, this plugin creates a unique mapping that explicitly pulls content from Vim into the system clipboard.

Usage

System copy provides a mapping to copy to the system clipboard using a motion or visual selection. It also provides a mapping for pasting from the system clipboard.

The default mapping is cp for copying and cv for pasting, and can be followed by any motion or text object. For instance:

  • cpiw => copy word into system clipboard
  • cpi' => copy inside single quotes to system clipboard
  • cvi' => paste inside single quotes from system clipboard

In addition, cP is mapped to copy the current line directly.

The sequence cV is mapped to paste the content of system clipboard to the next line.

Clipboard Utilities

  • OSX - pbcopy and pbpaste
  • Windows - clip and paste
  • Linux - xsel on X11, and wl-copy and wl-paste on Wayland

Note: xsel can be installed with apt-get install xsel if your system doesn't have it installed.

  • OS-independent copy - provided by ojroques/vim-oscyank based on ANSI OSC52 sequence

Note: This feature requires an external plugin ojroques/vim-oscyank and needs to be manually enabled. The terminal emulators that support this feature are listed here.

Options

Customizing copy & paste command

system-copy uses default copy and paste command based on your OS, but you can override either of these commands if you have more specific needs.

To declare custom copy command use following example:

let g:system_copy#copy_command='xclip -sel clipboard'

And to declare custom paste command use:

let g:system_copy#paste_command='xclip -sel clipboard -o'

Supressing message output

By default system_copy prints a message each time you execute the copy- or paste-operation. If you want to suppress it use:

let g:system_copy_silent = 1

Using OSC52 copy as fallback

OSC52 is an ANSI escape sequence that allows you to copy text into your system clipboard from the supported terminal emulators.

It is useful for running Vim via remote SSH, especially when the default copy command or X11 forwarding is unavaliable on the remote host. Once this feature is enabled, OSC52 copy sequence is used as a fallback if the default copy command failed. You can enable this feature on your local machine with ojroques/vim-oscyank plugin and the supported terminal emulator installed:

let g:system_copy_enable_osc52 = 1

Note: By default, no extra settings for ojroques/vim-oscyank are required. Only works when copying to the system clipboard; does not support pasting from the system clipboard.

Installation

If you don't have a preferred installation method, I recommend using Vundle. Assuming you have Vundle installed and configured, the following steps will install the plugin:

Add the following line to your ~/.vimrc and then run :PluginInstall from within Vim:

call vundle#begin()
" ...
Plugin 'christoomey/vim-system-copy'
" ...
call vundle#end()

More Repositories

1

vim-tmux-navigator

Seamless navigation between tmux panes and vim splits
Vim Script
5,206
star
2

dotfiles

My vim, zsh, git, tmux, and other config files and utility scripts.
Shell
466
star
3

vim-tmux-runner

Vim and tmux, sittin' in a tree...
Vim Script
291
star
4

vim-conflicted

Easy git merge conflict resolution in Vim
Vim Script
271
star
5

vim-sort-motion

Vim mapping for sorting a range of text
Vim Script
250
star
6

your-first-vim-plugin

Samples and notes for my Aug 2014 'Your First Vim Plugin' talk
Vim Script
129
star
7

vim-titlecase

Teach Vim about titlecase, with support for motions and text objects
Vim Script
103
star
8

vim-quicklink

A Vim plugin for quickly looking up a topic in google and inserting the relevant link
Vim Script
55
star
9

boston-react-conf-2018-graphql-talk

Sample repo for my Boston React Conf 2018 talk on React & GraphQL
JavaScript
31
star
10

vim-run-interactive

Vim plugin to run shell commands in an interactive shell
Vim Script
26
star
11

vim-rfactory

Vim plugin for rapid navigation to FactoryBot factory definition
Ruby
23
star
12

display-table-summary

Vim Script
8
star
13

vim-presentation-mode

Vim Script
8
star
14

vim-textobj-codeblock

Vim Script
7
star
15

alfred-trello-boards

Alfred workflow for quick navigation to Trello boards
Ruby
7
star
16

vim-kata-meetup

Support repo for 2012-11-12 Boston Vim meetup
Ruby
5
star
17

ctrlp-generic

A generic list selection extension to CtrlP for vim
Vim Script
4
star
18

magictags

Automatic generation of tags file from Vim
Vim Script
4
star
19

vim-g-dot

Vim command to repeat last change over a number of lines
Vim Script
4
star
20

typescript-intro-presentation

3
star
21

live-down

Markdown rendering and live-reloading
3
star
22

conway

jQuery & coffeescript implementation of Conway's Game of Life
CoffeeScript
3
star
23

vim-colors-ctoomey

My colorschemes for vim
Vim Script
3
star
24

react-native-graphql

JavaScript
2
star
25

emit

Fun with canvas animation
Ruby
2
star
26

zero

A web app to monitor your inbox zero status over time
Ruby
2
star
27

elm-reaction

Elm
1
star
28

gsub.vim

Vim Script
1
star
29

inertia-svelte-repro

Ruby
1
star
30

vim-swiki

Vim plugin for simple wiki management
Vim Script
1
star
31

trusted-local

Vim Script
1
star