Подтвердить что ты не робот

Ширина заставки Spacemacs

Я просто перешел из VIM в Spacemacs и хотел бы изменить ширину закладки по умолчанию (\ t?) только на 2 пробела. Я нашел команды вроде

(setq-default indent-tabs-mode nil)

и

(setq tab-width 4) ; or any other preferred value
(defvaralias 'c-basic-offset 'tab-width)
(defvaralias 'cperl-indent-level 'tab-width)

Моя проблема в том, что я не знаю, правильны ли они, где в файле .spacemacs я должен вставить их и что они даже означают.

4b9b3361

Ответ 1

Я нашел эту статью: http://blog.binchen.org/posts/easy-indentation-setup-in-emacs-for-web-development.html

Я добавил эту часть кода в мой файл .spacemacs вне любой функции (но до (defun dotspacemacs/user-init () ... )):

(defun my-setup-indent (n)
  ;; java/c/c++
  (setq c-basic-offset n)
  ;; web development
  (setq coffee-tab-width n) ; coffeescript
  (setq javascript-indent-level n) ; javascript-mode
  (setq js-indent-level n) ; js-mode
  (setq js2-basic-offset n) ; js2-mode, in latest js2-mode, it alias of js-indent-level
  (setq web-mode-markup-indent-offset n) ; web-mode, html tag in html file
  (setq web-mode-css-indent-offset n) ; web-mode, css in html file
  (setq web-mode-code-indent-offset n) ; web-mode, js code in html file
  (setq css-indent-offset n) ; css-mode
  )

и добавил строку

(my-setup-indent 2) ; indent 2 spaces width

в (defun dotspacemacs/user-init () ... ) следующим образом:

(defun dotspacemacs/user-init ()
  "Initialization function for user code.
It is called immediately after `dotspacemacs/init', before layer configuration
executes.
 This function is mostly useful for variables that need to be set
before packages are loaded. If you are unsure, you should try in setting them in
`dotspacemacs/user-config' first."
  (my-setup-indent 2) ; indent 2 spaces width
  )

Ответ 2

Вы также можете просто настроить переменную standard-indent, установив ее в 2, вызвав команду customize-variable в пределах spacemacs. Это сохранит настройку в вашем файле .spacemacs.

Edit:

для запуска 'customize-variable' используйте горячую клавишу M-x (alt-x для большинства систем), затем введите в приглашение команду customize-variable.

вы можете использовать поиск для поиска "стандартного отступа"