When I type a close bracket in emacs, the minibuffer shows the line that contains the matching open bracket. Is there a way to display the matching line of a bracket, parenthesis etc in the minibuffer without deleting the bracket and retyping it?
I assume you have turned on show-paren-mode so matching parens are highlighted:
(show-paren-mode t)
Then this will show the matching line if the paren is off the screen:
(defadvice show-paren-function (after my-echo-paren-matching-line activate)
"If a matching paren is off-screen, echo the matching line."
(when (char-equal (char-syntax (char-before (point))) ?\))
(let ((matching-text (blink-matching-open)))
(when matching-text
(message matching-text)))))
You can do M-x blink-matching-open RET
and if you like to use it often, bind it to a key.
scotfrazer's answer works great for parens, braces etc, but if you need to match ruby def...end or class...end delimiters (or similar in other languages) this answer from emacs.stackexchange works great:
(defvar match-paren--idle-timer nil)
(defvar match-paren--delay 0.5)
(setq match-paren--idle-timer
(run-with-idle-timer match-paren--delay t #'blink-matching-open))
The matching (off-page) delimiter will be highlighted if you pause the cursor on a delimiter for .5 seconds or longer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With