On Nov 18, 2013, at 9:31 AM, Bee <[email protected]> wrote:
>> write your selected text to the command "!pbcopy",
>> will put it on the system clipboard
>
> How do you 'write' selected text to "!pbcopy"?
The OS X command "pbcopy" reads from stdin, and puts whatever it gets
onto the system clipboard. How you use it depends on how you've
selected your text. To put the entire current buffer onto the
clipboard:
:w !pbcopy
To put a range of lines onto the clipboard, use commands like:
:5,10w !pbcopy
:.,$w !pbcopy
.'a,'bw !pbcopy
:'<,'>w !pbcopy
You could also put something like this in your ~/.vimrc:
nnoremap <silent> <Leader>c :Copy<CR>
vnoremap <silent> <Leader>c :Copy<CR>
command! -range Copy call DoCopy(<line1>, <line2>)
func! DoCopy(sline, eline)
exec ':' . a:sline . ',' . a:eline . 'w !pbcopy'
redraw
echohl ModeMsg
echon "Copied lines " a:sline "-" a:eline " to system clipboard"
echohl None
endfunc
ought to let you use "\c" to copy the current line, or select some text
in Visual mode and use "\c" to select it, or simplify the lines in the
second example above to commands like:
:5,10 Copy
Others here could probably improve the VimScript above; it's not my
native tongue.
Make sense?
Cheers,
Carl
--
--
You received this message from the "vim_mac" 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_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.