Click to See Complete Forum and Search --> : emacs - syntax highlighting
yopie
02-17-2003, 02:29 PM
Hi,
I'm just wondoring, is it possible to have syntax highlighting (eg for html, and java) and automatic indenting (so I dont have press TAB key every new line) using emacs?
How is to set this feature in emacs?
Or can anyone suggest other editor that have this capabilities?
Thanks,
GaryJones32
02-19-2003, 01:02 AM
lets see i will post some code from my .emacs file
mine does what you say but what makes it do that is an emacs mystery..
try these
(cond ((fboundp 'global-font-lock-mode)
(global-font-lock-mode t)
(setq font-lock-maximum-decoration t)))
if that doesn't work you can turn them on individually
(add-hook 'c-mode-hook 'turn-on-font-lock)
like that
seems like that would do it
there are lots of options like you can set the c and c++ coding style you want it to follow but basically if you have the modes installed
and i think it comes now all ready to go it should work
with indentation already
it works on file extensions so until you save the file or start emacs like
emacs new.cpp it won't be in the right mode !
since no one ever asks emacs questions i give you some keyboard shortcuts
mark an area or Cntrl-x h to select all
Alt-Cntrl-\ will properly indent that area or whole page
Cntrl-c Cntrl-q will indent a function
Alt-Cntrl e move to end of function
Alt-Cntrl a move to begining of function
Alt-x comment-region will comment out an area
Alt-x compile will run make
Cntrl-` visit code of next error message
here are some other lines out of my .emacs you can try
(global-set-key [delete] 'delete-char)
(global-set-key [kp-delete] 'delete-char)
(setq default-major-mode 'text-mode)
(setq-default transient-mark-mode t)
(setq-default case-fold-search nil)
(setq spell-command "spell +~/.spell")
(setq pop-up-frames t)
(setq-default shell-cd-regexp nil)
(setq-default shell-pushd-regexp nil)
(setq-default shell-popd-regexp nil)
(add-hook 'comint-output-filter-functions
'comint-watch-for-password-prompt)
(define-mail-alias "someone" "someone@xxx.com")
(setq mail-default-reply-to "Me@xxx.com")
there is a mode called html-helper-mode
that you might like to use
(setq html-helper-build-new-buffer t)
(setq tempo-interactive t)
(setq html-helper-mode-do-write-file-hooks t)
anyway some of this stuff might help
some might not work with certain versions ??
if you need the editor to respond to other file etensions you build
outo-mode-alist
like
(setq auto-mode-alist
(cons '("\\.py$" . python-mode) auto-mode-alist))
emacs can even interact with version controll !
happy coding