help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Emacs newbie - Syntax Highlighting and Indentation


From: Artur Hefczyc
Subject: Re: Emacs newbie - Syntax Highlighting and Indentation
Date: Fri, 14 Nov 2003 20:20:59 +0200
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3.50 (gnu/linux)

David Rasmussen <address@hidden> writes:
> 1) How do I enable syntax highlighting by default, for any type of file /
>    extension / mode that supports it? I have enabled it in the Options menu, 
> and
>    saved my options. But isn't there a non-menu-way of doing this, so I can 
> get
>    to learn and understand how to configure emacs myself?

Right way to customize emacs is to edit .emacs file in your home
directory. It is easy to find on Unix like systems but windows have
'home' directory in many different locations. So I suggest to look for
your .emacs file on HDD. It should be there, because you saved your settings.

It contains elisp code in most cases setting many different variables.
Here is my .emacs file in use on both systems - Windows and Linux:
http://wttools.sourceforge.net/emacs-stuff/emacs.html

It is rather big file but don't panic, you don't need to start with all
these settings. Many of them are commented in this file.

> 2) When I edit a java file, the Java major mode i automatically loaded. But 
> when
>    I press TAB at the beginning of a new line, i get an indentation of 4
>    spaces. How do I alter this to 2 spaces instead? Or any other number of
>    spaces? What if I want to get a tab character instead of spaces, when
>    indenting (I really don't, but I would like to know)?

The shortest answer to your question is:

Put to your .emacs file following code:
(setq c-basic-offset 2)

Other setting you might find useful for Java coding are:
(setq tab-width 4
      indent-tabs-mode nil)

However for Java coding I recommend JDEE package for emacs. I have been
using it for 3 years and I am very satisfied with it.
You can find more information about (installation, setup and use) it in
article I work on at following address:
http://wttools.sourceforge.net/emacs-stuff/emacsandjdee.html

If you need more info just ask.

Artur
-- 
Artur Hefczyc, Open Source Developer:
http://www.geotools.org/
http://generguide.sourceforge.net/
http://wttools.sourceforge.net/
http://maven-plugins.sourceforge.net/


reply via email to

[Prev in Thread] Current Thread [Next in Thread]