Saturday, November 8, 2014

Re: Selectively using system clipboard from vim in iTerm2 (Mac)

* Tim Johnson <tim@akwebsoft.com> [141108 11:52]:
> I'm using vim 7.4 Huge version without GUI on Mac OS X 10.7. This
> version is installed from Macports.
>
> I launch it from iTerm2 and frequently from MC running in iTerm2 as
> it is my default MC editor.
>
> options include +clipboard, +python, -xterm_clipboard, -xterm_save.
>
> With clipboard=unnamed I can copy to the system clipboard. However,
> as it is configured now, that's too much of a good thing as any
> delete (example ddp) ends up in the system clipboard and I want to
> be able selectively copy to the system clipboard *without* using
> visual mode (as opposed to selecting by mouse/trackball).
>
> I've written quite a few simple vimscripts and I could do something
> along the following lines :
> 1)set clipboard=unnamed
> "" copy or cut and insert in sys clipboard
> 2)set clipboard=""
>
> But I'd to inquire if there is something done already that might be
> recommended. I'm happy to do my own work, but there is so many
> better vimscripters out there ....
I found the following pbcopy.vim script
" File: pbcopy.vim
" Author: Tom Stuart
" Version: 1.0
" Last modified: February 7, 2011

function! s:pbcopy()
"call system("ssh localhost pbcopy", getreg(""))
call system("pbcopy", getreg(""))
endfunction
command! -nargs=0 -bar PBCopy call s:pbcopy()

Note that I commented out the first system call and added the
modified one with 'ssh'.
And the following keymappings:
noremap ;c :PBCopy<CR>
vmap ;c :PBCopy<CR>

so the resulting action is y;c ...

As of yet, the vimscript not portable 'tho - since linux won't
recognize pbcopy, I would guess that xsel would be the option for
linux.

This gets me going.
cheers
--
Tim
tim at tee jay forty nine dot com or akwebsoft dot com
http://www.akwebsoft.com, http://www.tj49.com

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: