2 blanks indentation
Sorry if this is a stupid question but is it possible to custamize php-mode so that it uses two blanks (instead of four blanks) of identation for indenting blocks? My php-code is already formatted in this way and it would like to keep the indentation.
Many thanks in advance,
Dirk
@dmelch
An easy way is to add the following code in the php-mode-hook of the Emacs initialization file.
(setq tab-width 2)
For example:
(add-hook 'php-mode-hook
(lambda()
(setq tab-width 2))
It is more recommended to set it with EditorConfig. See https://editorconfig.org/ and editorconfig-emacs.
Hallo zonuexe
thank you for your help but unfortunately it didn't help, there are still 4 blanks used for indentation when using php-mode.
Dirk
I think c-basic-offset may be the variable you need to set?
Don't have time to check now, but wanted to mention it before I forget I saw this thread.
@NateEag
thank you very much that worked for me! I put
(add-hook 'php-mode-hook (lambda() (c-basic-offset 2))
in my .emacs file
Dirk
sorry, this is correct:
(add-hook 'php-mode-hook (lambda() (setq c-basic-offset 2))
Dirk
Awesome. Glad I could help.
@zonuexe Think it'd be worth it if I could find a few minutes to expand the documentation to mention c-basic-offset in the coding style section?
Yes I think that's a good idea!