How can I set a tab width for JSON files?
(add-hook 'json-mode-hook (lambda () (make-local-variable 'js-indent-level) (setq js-indent-level 2)))
Make the variable buffer local so that it does not conflict with js-mode
for JavaScript files.
I used M-x customize
as mentioned here: How to change the indentation width in emacs javascript mode
It inserted '(js-indent-level 2))
into my .emacs file.
But thanks for the response anyway.
it's better to set tab width in the corresponding hook - find the name of major mode (for example, by using the M-: major-mode
, and then define the hook where to set the value:
(defun my/json-mode-hook () (setq tab-width 4))(add-hook 'json-mode-hook 'my/js2-mode-hook)