Tips
v - visual mode (for copy) y - yank (copy)
- copy selected part: visually select text(type v or V in normal mode) and type :w !pbcopy
- copy the whole file :%w !pbcopy
- paste from the clipboard :r !pbpaste
On most Linux Distros, you can substitute:
- pbcopy above with xclip -i -sel c or xsel -i -b
- pbpaste using xclip -o -sel -c or xsel -o -b -- Note: In case neither of these tools (xsel and xclip) are preinstalled on your distro, you can probably find them in the repos