There is built-in emacs function for surrounding a region with parenthesis, as I found it here: https://stackoverflow.com/a/2952021/1635919. Is there an analogous way to surround a region with dollar ($)?
C-h f insert-pair
tells that this function is able to surround sexp with any character, so how to bind surrounding with $ to M-$
as in the linked answer?
My Emacs: GNU Emacs 24.3.1 (i686-pc-linux-gnu, GTK+ Version 3.10.7)
You can duplicate what M-( does by looking at the insert-parentheses function. All it does is call insert-pair with hardcoded parameters, so you can analagously bind M-$ to the following function:
(defun insert-dolla-dolla-bills-yall (&optional arg)
(interactive "P")
(insert-pair arg ?\$ ?\$))