Shortcodes work via Shortcode API. Essentially shortcode is just a human-friendly form of writing out data that is processed and passed to associated PHP function.
So adding your own shortcode involves:
- Coding PHP function that would process data, passed by API from shortcode.
- Registering that function as shortcode handler.
I also remember WP Utility Short Codes plugin was recommended in answer to some question while back as good way to insert snippets and such in editor.