Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 10-15-2009, 08:54 AM   #1
LQ Newbie
Registered: Oct 2009
Distribution: Debian Lenny
Posts: 6

Rep: Reputation: 0
Emacs indentation

I'm trying to get used to advanced text editors. I've started with vim, and now switched to emacs. However, emacs indentation drives me crazy. Things like

int main(void)
    if (n == 1)
and so on

I just want it to be similar like VIM's:

 99 ········set expandtab "no real tabs, spaces instead
102 ········set softtabstop=4 " when hitting tab or backspace, how many spaces
103                         "should a tab be (see expandtab)
104 ········set tabstop=8···"real tabs should be 8, and they will show with
106 ········set autoindent
107 ········set smartindent
109 ········set listchars=tab:··
110 ········set list
so the code will look like

  7 int main(void)
  8 {
  9     int a, b, num = 0, errors, i;
 11     srand(time(NULL));
 13     while (true)
 14     {
 15         errors = 0;
 17         for (i = 1; i <= 10; i++)
 18         {
 19             a = rand() % 10;
 20             b = rand() % 10;
and it can be handy to emphasis real tabs too. Also when I hit enter, I want emacs to place the cursor in the same indentation position (106 ········set autoindent).

Thank you for your attention.
Old 10-15-2009, 09:01 AM   #2
Senior Member
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
I'm a big fan of Emacs, but when you newline, you can hit tab to bring your cursor over to the indentation position, or you can just type out your next statement, and when you type in any of the "(", "{", "[" or ";" characters, it will automatically indent it for you.

Here's a link to the Emacs manual:


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Emacs syntax-driven indentation problem moo-cow Programming 7 01-15-2007 06:52 AM
emacs' html indentation prell Linux - Software 1 05-26-2005 07:21 PM
auto indentation ilnli Programming 3 03-27-2005 07:14 PM
improving indentation in Kate JustinHoMi Linux - Software 4 02-12-2005 01:27 AM
emacs: requiring tabs in all indentation prell Linux - Software 0 08-24-2004 09:32 AM > Forums > Linux Forums > Linux - Newbie

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

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