I would do it like this:
Put this function in your vimrc:
function Test() range echo system('echo '.shellescape(join(getline(a:firstline, a:lastline), "\n")).'| pbcopy') endfunction
This will allow you to call this function by doing:
:'<,'>call Test()
Then you can also map this like this (just under the function declaration in your vimrc):
com -range=% -nargs=0 Test :<line1>,<line2>call Test()
So you can call the function:
:'<,'>Test
Note. :<','> are range selectors, so that you can simply select the corresponding lines in visual mode, and then go into command mode (pressing the colon key)
matias Apr 6 '10 at 14:40 2010-04-06 14:40
source share