LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 04-20-2010, 11:01 AM   #1
cola
Senior Member
 
Registered: Sep 2007
Location: Dhaka,Bangladesh
Distribution: Debian
Posts: 1,031

Rep: Reputation: 63
How to enable autoindent in Emacs?


How to enable autoindent in Emacs?
 
Old 04-20-2010, 03:04 PM   #2
indienick
Senior Member
 
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
http://www.emacswiki.org/emacs/AutoIndentation

Google is your friend.
 
Old 04-20-2010, 07:23 PM   #3
cola
Senior Member
 
Registered: Sep 2007
Location: Dhaka,Bangladesh
Distribution: Debian
Posts: 1,031

Original Poster
Rep: Reputation: 63
Quote:
Originally Posted by indienick View Post
I added this in .emacs
Code:
     (dolist (command '(yank yank-pop))
       (eval `(defadvice ,command (after indent-region activate)
                (and (not current-prefix-arg)
                     (member major-mode '(emacs-lisp-mode lisp-mode
                                                          clojure-mode    scheme-mode
                                                          haskell-mode    ruby-mode
                                                          rspec-mode      python-mode
                                                          c-mode          c++-mode
                                                          objc-mode       latex-mode
                                                          plain-tex-mode))
                     (let ((mark-even-if-inactive transient-mark-mode))
                       (indent-region (region-beginning) (region-end) nil))))))
But the indentation works after a sentence is completed.For example in .c or .cpp file after typing the semicolon( indentation is completed.

If i hit Enter the cursor will be in the correct position for a paragraph/block.
How can it be like vim indentation after hitting Enter?
 
Old 04-20-2010, 07:30 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Silly question, but ... why don't you just use vim instead of trying to make
emacs act like vim?
 
Old 04-20-2010, 07:34 PM   #5
cola
Senior Member
 
Registered: Sep 2007
Location: Dhaka,Bangladesh
Distribution: Debian
Posts: 1,031

Original Poster
Rep: Reputation: 63
Quote:
Originally Posted by Tinkster View Post
Silly question, but ... why don't you just use vim instead of trying to make
emacs act like vim?
I use vim.
But i want to know is it possible to have that vim insert mode in Emacs?
 
Old 04-21-2010, 04:36 AM   #6
ahappypengiun
LQ Newbie
 
Registered: Apr 2010
Posts: 2

Rep: Reputation: 1
It is indeed possible. Put this in your .emacs config file:

(global-set-key (kbd "RET") 'newline-and-indent)
 
1 members found this post helpful.
Old 04-21-2010, 05:30 AM   #7
cola
Senior Member
 
Registered: Sep 2007
Location: Dhaka,Bangladesh
Distribution: Debian
Posts: 1,031

Original Poster
Rep: Reputation: 63
Done.Thank you.
 
  


Reply


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: Enable minor mode in all buffers nb85 Programming 4 12-18-2014 11:32 AM
How do I enable emacs Backspace on remote logins? jkcunningham Linux - General 18 09-21-2009 04:51 PM
X editor with autoindent feature? rafa_gallego Linux - Software 5 07-31-2007 06:36 AM
How to stop emacs trying to autoindent php script lostjohnny Linux - Newbie 3 07-11-2006 12:17 PM
autoindent in eclipse/CDT spuzzzzzzz Linux - Software 0 07-23-2004 07:27 PM


All times are GMT -5. The time now is 04:32 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration