aboutsummaryrefslogtreecommitdiffstats
path: root/bundle/copy
diff options
context:
space:
mode:
authorTeddy Wing2015-11-11 20:11:34 -0500
committerTeddy Wing2015-11-11 20:11:34 -0500
commitf313554c25a6b6cf6044bd6fb3038f484d1507d3 (patch)
treecb1f9392d68337f2e559f02e8d4b455bdc941a2d /bundle/copy
parentf644bf199ec806cbf7d9d6ce53e52528abd6477e (diff)
downloaddotvim-f313554c25a6b6cf6044bd6fb3038f484d1507d3.tar.bz2
Create 'copy' plugin
A custom plugin that invokes a system copy to OS X's pasteboard using `pbcopy` via a Vim command. This allows us to specify a range of lines to copy in command mode, similar to the way that Chris Toomey's System Copy plugin provides an easy way to invoke a system copy using motions. With this plugin we can write: :5,21Copy to copy those lines. :12,'aCopy will also work. If your Vim is compiled with `+clipboard` support, you would instead write: :15,24y * Since I use a Vim that doesn't have clipboard support, I decided to use a plugin to get the same functionality rather than compile a new Vim.
Diffstat (limited to 'bundle/copy')
-rw-r--r--bundle/copy/autoload/copy.vim4
-rw-r--r--bundle/copy/plugin/copy.vim5
2 files changed, 9 insertions, 0 deletions
diff --git a/bundle/copy/autoload/copy.vim b/bundle/copy/autoload/copy.vim
new file mode 100644
index 0000000..c71c6d6
--- /dev/null
+++ b/bundle/copy/autoload/copy.vim
@@ -0,0 +1,4 @@
+function! copy#Copy(start_line, end_line)
+ silent execute a:start_line . ',' . a:end_line . 'y'
+ silent call system('pbcopy', getreg('@'))
+endfunction
diff --git a/bundle/copy/plugin/copy.vim b/bundle/copy/plugin/copy.vim
new file mode 100644
index 0000000..1383eca
--- /dev/null
+++ b/bundle/copy/plugin/copy.vim
@@ -0,0 +1,5 @@
+" Copy
+"
+" Takes a range and copies the lines specified to the system clipboard.
+
+command! -range Copy call copy#Copy(<line1>, <line2>)