The relevant section in my .emacs file looks as follows:

(require 'smartparens)
(smartparens-global-mode t)
(require 'smartparens-config)
;; for erb
(sp-pair "%" "%" :wrap "C-%")

I am often getting extra sets of quotes when typing the final quote in a pair rather than the final quote being overwritten, as expected and am trying to figure out what the cases this happens in are, and if there is a resolution. I a big part of the problem is that the closing pair member is the same as the opening pair member.


Type "<any single character><backspace>"

Typing the first quote generates the second, but when typing the above sequence, I would expect for the final quote to be overwritten, as it does when you omit the <backspace> keystroke.

Another example:

Type "" Outputs: """"

I'm not really sure if there is a good, general solution to this, as there may be cases in which this behaviour is desired. Feel free to edit this question with more examples.


Overwriting closing pair is called "autoskipping". By default it works only on "active sexp", that is, when user only moves cursor forward after opening delimiter. If user moves cursor backwards the sexp becomes "inactive" and smartparens inserts another pair of delimiters.

There is a variable called sp-cancel-autoskip-on-backward-movement, that controls whether the sexp stays active if user moves cursor backwards. Setting it to nil will give you behavior you want.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.