smartparens-mode doesn't suit my style of editing. If I attempt to disable it globally in spacemacs, however, the mode is re-enabled:
How do I disable smartparens-mode?
You can add
smartparens to the
dotspacemacs-excluded-packages list of your dotfile.
Spacemacs uses the concept of toggles to enable/disable minor-modes per buffer. Toggles are grouped under SPC t and SPC T, but they only switch for the current buffer. You can temporarily disable smartparens for the current buffer by pressing SPC t p (
But if you want to disable smartparens for every buffer permanently, put
spacemacs/toggle-smartparens-globally-off in your
dotspacemacs/user-config function. To do that, press SPC f e d, this will open your
.spacemacs file. Then make sure you have something like this:
(defun dotspacemacs/user-config () "Configuration function for user code. This function is called at the very end of Spacemacs initialization after layers configuration. You are free to put any user code." ; other code (spacemacs/toggle-smartparens-globally-off) ; other code )
smartparens-global-mode is a global mode. If it is enabled you get smartparens-mode in every buffer. Turning it off does not prevent you from turning on smartparens-mode anywhere. (That would be silly, because if that were true there would be no way to selectively enable smartparens. It would be either everywhere or nowhere, depending on that mode.) In fact smartparens-global-mode is off by default already.
Spacemacs enables smartparens-mode in all programming buffers by switching it on in the hook. Therefore you have to remove the function from prog-mode-hook.
To remove the function from the
prog-mode-hook, add the following line to
(remove-hook 'prog-mode-hook #'smartparens-mode)
If you don't have smartparens-mode disabled by default, you can also add the following line:
Note that if you exclude the
smartparens package as suggested in another answer, you'll lose some other features such as
SPC j n (
Here's how to selectively enable smartparens only in specific modes
(defun dotspacemacs/user-config () (require 'smartparens) (remove-hook 'prog-mode-hook #'smartparens-mode) (remove-hook 'markdown-mode-hook #'smartparens-mode) (spacemacs/toggle-smartparens-globally-off) (add-hook 'clojure-mode-hook '(lambda () (smartparens-mode 1)) t))
Add entry/exit hooks for evil insert mode:
;; Defeat smartparens-mode in evil mode (add-hook 'evil-insert-state-entry-hook 'turn-off-smartparens-mode) (add-hook 'evil-insert-state-exit-hook 'turn-on-smartparens-mode)
In spacemacs hybrid mode, apply to the evil-hybrid-state hooks:
;; Alternative way to defeat smartparens-mode in hybrid mode (add-hook 'evil-hybrid-state-entry-hook 'turn-off-smartparens-mode) (add-hook 'evil-hybrid-state-exit-hook 'turn-on-smartparens-mode)