On Sat, 13 Mar 1999, Chris wrote:

> I was wondering how to make vim do syntax highlighting for C code or emacs
> and how to set tabs for code.

Emacs should distinguish different source codes and switch to the
approperaite mode (c-mode, c++-mode, latex-mode, html-mode, etc.). You can
check that by looking at bottom of emacs window. At any rate, if you want
to change the mode (for example if the source code has the wrong extension
or for whatever reason), you can type, say for c-mode, "Esc x c-mode".

The above takes care of tabs, indentation, etc. If you want color
highliting in any mode, you can type "Esc x font-lock-mode".

Now to make emacs remember your preferences the next time you load it up,
you'll need to add some commands to your ~/.emacs file. Let's say you
program in PHP and you want emacs to open .php3 files as C files and
hilight the syntax. You put the following two lines in ~/.emacs:
(setq font-lock-mode t)
(setq auto-mode-alist (cons '("\\.php3$" . c-mode) auto-mode-alist))


You only need one font-lock-mode command in the file, but for any
non-standard file extension, you need to tell emacs which mode it should
use.

Hope this helps.


cheers,
Hossein

Reply via email to