I’m looking for a more elegant way of doing this
function PasteBin() range
let l:stdin = join(getline(a:firstline, a:lastline), "^M")
let l:output = system("pb", l:stdin)
echo l:output
endfunction
Specifically, how can I avoid using getline() and join()?
Looks like you’re just reinventing :w_c. If you already have a visual selection, you can just run
to use the visual selection as the stdin for pb.