Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2 blanks indentation #646

Open
dmelch opened this issue Nov 6, 2020 · 8 comments
Open

2 blanks indentation #646

dmelch opened this issue Nov 6, 2020 · 8 comments
Labels

Comments

@dmelch
Copy link

dmelch commented Nov 6, 2020

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

@zonuexe
Copy link
Member

zonuexe commented Nov 8, 2020

@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.

@dmelch
Copy link
Author

dmelch commented Nov 9, 2020

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

@NateEag
Copy link
Member

NateEag commented Nov 10, 2020

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.

@dmelch
Copy link
Author

dmelch commented Nov 11, 2020

@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

@dmelch
Copy link
Author

dmelch commented Nov 11, 2020

sorry, this is correct:

(add-hook 'php-mode-hook
(lambda()
(setq c-basic-offset 2))

Dirk

@NateEag
Copy link
Member

NateEag commented Nov 11, 2020

Awesome. Glad I could help.

@NateEag
Copy link
Member

NateEag commented Nov 11, 2020

@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?

@dmelch
Copy link
Author

dmelch commented Nov 12, 2020

Yes I think that's a good idea!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants