Occasionally I yank code into a paredit-mode
buffer that is missing a closing parenthesis or bracket. paredit-mode
then detects the unclosed expression and tries to add the missing paren in the wrong place. This is frustrating when I move the cursor to the point where I want the close paren but I can't put it there. I end up having to switch off paredit-mode
.
Here's an example:
I've just yanked
[["https://github.com/aconbere/yesql.git"
"aea69ebd4a7788a66fc8689fea7e806f1463c347"]
but paredit-mode
sees a missing )
at the very end (in red). I'm not even sure why it wants to use a close parens when the opening is a bracket. Typing ]
at the point makes the cursor jump to the end and try to fill in the red paren. Slurping or barfing don't have the intended effects and simply move the )
around.
Is there any way to fix this without temporarily disabling paredit-mode
?
kill-region
(bound by default to C-w
) and quoted-insert
(bound by default to C-q
) are unaffected by paredit mode. You can delete regions or insert matching delimiters using these keybindings, bypassing paredit rules. Remember that you can also turn off paredit, clean something up, and then turn it back on again.
Others have already mentioned C-q
for quoted-insert. You can also use C-u DEL
or C-u C-d
to override paredit's normal balanced behavior of DEL
and C-d
for a single deletion:
(foo)|)
C-u DEL
(foo|)
Trust me. By far the easiest is to paste a bracket or parentheses.
You can do:
; ]
and then copy it
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