How to add space between Mac OS X dock icons

Standard

Open Terminal and copy and paste this command:

defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type="spacer-tile";}'

and then restart dock:

killall Dock

The dock will refresh with an added space that can be dragged to any position (or removed by dragging it off the dock). Repeat the commands to add more spacer.