I'm using smartparens-global-strict-modeand having issues quoting variables. How do I get something like 'varname? My current strategy, which seems ridiculous, is to do:

'|' (sp inserts both pairs)

'varname' (write the varname)

at this point, I do M-x smartparens-strict-mode, which toggles it off, delete the right ', then do M-x smartparens-strict-mode again to turn it back on. But there's got to be a better way, right? Am I missing something simple?

3 Answers 3


Specific answer: The default configuration for smartparens should cover this, but perhaps you aren't loading the default config. Make sure that

(require 'smartparens-config)

is in your .emacs.d instead of just (require 'smartparens).

More generally, to see the delimiters that smartparens is currently tracking, inspect variable sp-pair-list. You can use the functions sp-pair and sp-local-pair to configure it. For example to globally disable autoinsertion of closing single quotes you can write:

(sp-pair "'" "'" :actions nil)

Or to disable for specific modes:

(sp-local-pair '(emacs-lisp-mode) "'" "'" :actions nil)

What major mode are you using? In emacs-lisp-mode, Smartparens does not automatically close single quotes.

To insert a single character, use C-q, quoted-insert, followed by the character. E.g. C-q ' to insert a single quote.

  • Huh. This happens in all major modes, including emacs-lisp-mode. I guess something else in my init file is causing that, then... The C-q tip works. Thanks for that.
    – Alex
    Aug 23, 2016 at 1:31

Eval (sp-pair "'" "'" :actions :rem) to disable any cleverness with the apostrophe. This removes the entry for ' from sp-pairs. You can get the right arguments to pass into sp-pair by evaling (sp-get-pair "'").

  • 1
    Can you elaborate, to explain how that sexp does what you say? That could make your answer more helpful.
    – Drew
    Aug 3, 2020 at 0:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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