3

I have only installed emacs straight out of the box. I have not installed anything else:

GNU Emacs 26.3
Copyright (C) 2019 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

enter image description here

my .emacs file:


;; Added by Package.el.  This must come before configurations of
;; installed packages.  Don't delete this line.  If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
(package-initialize)

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(custom-enabled-themes (quote (wombat))))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )

(when (version<= "26.0.50" emacs-version )
  (global-display-line-numbers-mode))

(setq-default indent-tabs-mode nil)
(setq-default tab-width 2)
(setq js-indent-level 2)

1 Answers1

4

Suppose your major-mode is css-mode.

You can place (setq-default css-indent-offset 2) into .emacs.

Or you can set up per buffer,

(defun my-setup-indent ()
  (setq-local css-indent-offset 2))
(add-hook 'prog-mode-hook 'my-setup-indent)
chen bin
  • 4,781
  • 18
  • 36