Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup emacs for Google Java Style

Tags:

java

emacs

I am surprised, but after searching, I cannot find an emacs configuration that I can use to have emacs follow Google Java Style.

If there is such a configuration already available I would appreciate links to it.

Otherwise, how would I create such a configuration?

UPDATE:

The most basic thing I would like to learn : what customization variables do I set to get 2 spaces for block indentation and 4 spaces for continuation lines?

like image 836
haroldcarr Avatar asked Dec 21 '25 08:12

haroldcarr


1 Answers

Put https://github.com/google/styleguide/blob/gh-pages/google-c-style.el on your load path, such as in ~/.emacs.d/.

Then, in your Emacs init file, add:

;; Also works for Java.
(autoload 'google-set-c-style "google-c-style")
(autoload 'google-make-newline-indent "google-c-style")
(add-hook 'c-mode-common-hook 'google-set-c-style)
(add-hook 'c-mode-common-hook 'google-make-newline-indent)
like image 136
mernst Avatar answered Dec 23 '25 22:12

mernst



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!