LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 12-29-2010, 04:17 PM   #1
ArthurHuang
Member
 
Registered: Jan 2006
Posts: 174

Rep: Reputation: 30
.emacs indent question


How can I set indent in .emacs to enable my new line starts from the same position of previous line?

like this;

Hello world <enter>
Second Hello world // "S" starts right under first line's "H"

If this is not indent related, please let me know other solutions.

Thanks!!
 
Old 12-29-2010, 11:24 PM   #2
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian
Posts: 2,396

Rep: Reputation: 814Reputation: 814Reputation: 814Reputation: 814Reputation: 814Reputation: 814Reputation: 814
Indentation in Emacs generally depends on the major mode, but usually TAB sets the correct indentation for the current line. C-j (Ctrl+J) is set to newline-and-indent by default, but you can set <return> to that by doing:
Code:
(define-key global-map (kbd "<return>") 'newline-and-indent)
 
Old 12-30-2010, 10:25 AM   #3
Snark1994
Senior Member
 
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,630
Blog Entries: 3

Rep: Reputation: 345Reputation: 345Reputation: 345Reputation: 345
Also, I'm guessing that you meant to do something like
Code:
    Hello world<ENTER>
Second "Hello World"
Using [CODE] tags preserves whitespace in your posts though if I've misunderstood your question, then I could just be babbling
 
Old 12-30-2010, 11:32 AM   #4
ArthurHuang
Member
 
Registered: Jan 2006
Posts: 174

Original Poster
Rep: Reputation: 30
Snacks, thanks for help. But this is not what I want.

I want this:

[4 spaces]Hello world<Enter>
[4 spaces]Second Hello world.

//The second line automatically aligns with the first line.

Quote:
Originally Posted by Snark1994 View Post
Also, I'm guessing that you meant to do something like
Code:
    Hello world<ENTER>
Second "Hello World"
Using [CODE] tags preserves whitespace in your posts though if I've misunderstood your question, then I could just be babbling
 
Old 12-31-2010, 02:45 PM   #5
Snark1994
Senior Member
 
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,630
Blog Entries: 3

Rep: Reputation: 345Reputation: 345Reputation: 345Reputation: 345
I meant when posting originally - your original post looked like this

Code:
Hello World
Second Hello World
while I felt you probably meant

Code:
    Hello World
Second Hello World
But ntubski's already answered your question, so it's academic
 
  


Reply

Tags
emacs


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 un-indent region jantman Linux - Software 4 12-28-2006 05:47 AM
PHP - getting a parse error after emacs indent-region BrianK Programming 1 12-16-2005 07:25 PM
indent cpp file with emacs~ black Linux - Software 10 09-10-2004 12:43 AM
failed on modifying indent on emacs~ black Linux - Software 0 07-22-2004 11:59 PM
emacs - convert auto indent tabs to spaces? BrianK Linux - General 1 04-15-2004 10:14 PM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration