LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-09-2003, 12:15 AM   #1
vanquisher
Member
 
Registered: Aug 2003
Location: Hyderabad, India
Posts: 126

Rep: Reputation: 15
EMACS newbie


Hey all,
I'm thinking of switcing from VI to Emacs. When I tried to code a C program (hello world ) using emacs, I'm not getting the indentation I get with VI...tabs and stuff. But the parantheses matching is very good. So, any idea how to make `vi-like' indentation work for emacs?
 
Old 09-09-2003, 05:08 AM   #2
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
is it in C or Fundamental mode? when you type the first character on a line it should put it in the correct place, or at least it does for me.
 
Old 09-09-2003, 05:36 AM   #3
vanquisher
Member
 
Registered: Aug 2003
Location: Hyderabad, India
Posts: 126

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by kev82
is it in C or Fundamental mode? when you type the first character on a line it should put it in the correct place, or at least it does for me.
When I start it with something like $ emacs test.c, it says "loading CC mode...done" and I understood that it is in C mode...alright. But with VI, when I type enter after main() {, the next line starts after a tab. Not the case with emacs. It's not a big problem, but I'd love to see emacs behave in the way vi did. I'm particular about the vi style of indentation.
 
Old 09-09-2003, 05:44 AM   #4
UltimaGuy
Member
 
Registered: Aug 2003
Location: Chennai, India
Distribution: PCLinuxOS .92, FC4
Posts: 840

Rep: Reputation: 32
The next line does not start with a tab by default. But, as you enter your code in it, and when you enter either a paranthesis, or semicolon, or some similar chars, the line is automatically indended. This provides a more effective indending mechanism, and also helps sort out some typo errors, atleast for me.

As you work more with it, you will understand its value.
 
Old 09-09-2003, 05:51 AM   #5
dakensta
Member
 
Registered: Jun 2003
Location: SEUK
Distribution: Debian & OS X
Posts: 194

Rep: Reputation: 35
Hitting tab or completing a statement performs the indentation, wherever you are on the line, according to your selected indentation style.

Moving the other way, on the rare occaisions I use vi, it is equally frustrating that hitting tab actually inserts a tab character

Emacs manual reference:
http://www.gnu.org/manual/emacs/html.../emacs_22.html
 
Old 09-09-2003, 11:14 AM   #6
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Below is what I have in my ~/.emacs file. It makes emacs use much different colors possible for syntax highlighting, enables auto-indention, auto-newline and auto-backspace. Put this at the end of your ~/.emacs file and retart emacs to check if it is what you are looking for.
Code:
(setq font-lock-maximum-decoration
  '((c-mode    . 3) 
    (c++-mode  . 3)
    (java-mode . 3)
    (jde-mode  . 3)
    (t         . 3))
)

(global-font-lock-mode t)
(show-paren-mode t)

(defun my-c-mode-common-hook ()
  (c-set-style "k&r")
  (c-toggle-auto-hungry-state t))

(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
where is the .emacs file in the emacs source code tarball? aizkorri Programming 2 01-13-2007 02:05 PM
emacs not responding to .emacs file in Mandriva 2005 LE. Please help LaptopLinux Mandriva 1 06-08-2005 08:36 AM
emacs kotoisin Linux - Newbie 4 04-22-2005 03:35 AM
edb (emacs database) won't open file - emacs 20 & 21 tip184 Linux - Software 0 04-03-2004 07:31 AM
Newbie emacs compile error neilcpp Programming 2 02-08-2004 05:33 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration