It's a bit tricky, but doable. As a bash
command:
bind '"(" "C-v()e[D"'
bind '""" "C-v"C-v"e[D"'
As a setting in .inputrc
(so any program using readline
gets the behavior):
"(": "C-v()e[D"
""": "C-v"C-v"e[D"
You can prefix each key with Control-v to type "plain" quotes and left parentheses without triggering the auto-close behavior.
The above assumes Emacs keybindings. For vi bindings, use
bind '"(": "C-v()ei"'
bind '""" "C-v"C-v"ei"'
or
"(": "C-v()ei"
""": "C-v"C-v"ei"
Essentially, just replace the [D
with i
; instead of sending the escape sequence to move the cursor left, just send e
to drop back into command mode after inserting the parentheses/quotes, then re-enter insert mode, which should position the cursor inside the characters just typed.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…