If you're using a good enough editor, you can set up all sorts of things to happen with a single keystroke. For example, I use xemacs, and I have
- Alt-p (or escape-p) insert a pair of parentheses and put point in between them,
- alt-m (or escape-m) insert a pair of dollar signs and put point in between them,
- alt-o (or escape-o) insert a pair of braces and put point in between them,
- alt-p (or escape-p) insert a pair of parentheses and put point in between them,
plus a few other things. To get out of them, I have alt-j (or escape-j) "jump out" of any of these, i.e., it moves forward until after the first right paren, right brace, or right bracket. I also have the key ^
insert that character along with a pair of braces and put point inside the braces, the key _
insert that character along with a pair of braces and put point inside the braces, and the key [
insert a pair of brackets and put point in between them.
I set this all up in my .xemacs/init.el
file; I'll append the relevant part of that file here.
;; Set up my LaTeX-mode keybindings:
(add-hook 'LaTeX-mode-hook 'add-my-latex-keybindings)
(defun add-my-latex-keybindings ()
(progn
(local-set-key "[" 'bracket-pair)
(local-set-key "^" 'superscript-braces)
(local-set-key "_" 'subscript-braces)))
;;--------------------------------------------------------------------
;;--------------------------------------------------------------------
;; This begins the definitions of our own functions:
;;--------------------------------------------------------------------
;;--------------------------------------------------------------------
(defun dollar-pair ()
"We insert a pair of dollar signs and position
point in between them."
(interactive)
(progn
(insert "$$")
(backward-char)))
;;---------------------------------------------------------------
;;---------------------------------------------------------------
(defun paren-pair (arg)
"We insert a pair of parentheses and position point in between them.
If called with an argument, then we insert \"\\bigl(\\bigr)\"
and position point inside of that."
(interactive "P")
(if arg
(progn
(insert "\\bigl(")
(save-excursion (insert "\\bigr)")))
(progn
(insert "()")
(backward-char))))
;;---------------------------------------------------------------
;;---------------------------------------------------------------
(defun brace-pair ()
"We insert a pair of braces and position
point in between them."
(interactive)
(progn
(insert "{}")
(backward-char)))
;;---------------------------------------------------------------
;;---------------------------------------------------------------
(defun bracket-pair ()
"We insert a pair of brackets and position
point in between them."
(interactive)
(progn
(insert "[]")
(backward-char)))
;;--------------------------------------------------------------------
;;--------------------------------------------------------------------
(defun superscript-braces ()
"We insert a superscript symbol followed by a pair of braces
and position point in between the braces."
(interactive)
(progn
(insert "^")
(brace-pair)))
;;--------------------------------------------------------------------
;;--------------------------------------------------------------------
(defun subscript-braces ()
"We insert a subscript symbol followed by a pair of braces
and position point in between the braces."
(interactive)
(progn
(insert "_")
(brace-pair)))
;;--------------------------------------------------------------------
;;--------------------------------------------------------------------
(defun insert-verbatim ()
"We insert \\verb\"\" and position point in between the quotes."
(interactive)
(progn
(insert "\\verb\"\"")
(backward-char)))
;;--------------------------------------------------------------------
;;--------------------------------------------------------------------
(defun jump-out ()
"We first expand the abbrev before point (if there is an abbrev
before point), and then we move point forward in the file until we
pass the first dollar sign, right paren, right bracket, right brace
or double quote."
(interactive)
(progn
(expand-abbrev)
(re-search-forward "[])}$\"]")))
;;--------------------------------------------------------------------
;;--------------------------------------------------------------------
(defun fontchange-em ()
"We insert \\emph{} and position point before the right brace."
(interactive)
(progn
(insert "\\emph{}")
(backward-char)))
;;---------------------------------------------------------------
;;---------------------------------------------------------------
;; Key bindings:
(global-set-key "\ej" 'jump-out)
(global-set-key "\C-cj" 'jump-out)
(global-set-key "\em" 'dollar-pair)
(global-set-key "\C-cm" 'dollar-pair)
(global-set-key "\ep" 'paren-pair)
(global-set-key "\C-cp" 'paren-pair)
(global-set-key "\eo" 'brace-pair)
(global-set-key "\C-co" 'brace-pair)
(global-set-key "\en" 'insert-verbatim)
(global-set-key "\C-cn" 'insert-verbatim)
(global-set-key "\ee" 'LaTeX-environment)
(global-set-key "\C-ce" 'LaTeX-environment)
(global-set-key "\ek" 'fontchange-em)
(global-set-key "\C-ck" 'fontchange-em)
\left[ \right]
and position the cursur in the middle), you can also assign media keys, all your mouse buttons (assuming you have more than the usual two) and also combos including your mousewheel. – Tom Bombadil Sep 9 '11 at 1:54