Reputation: 1082
Is there a simple primitive indentation mode for Emacs that would do the following:
When I go to new line (Hit Enter), copy whatever white space used for indentation for above line
When I press Tab, insert indentation character(s) that can be configured (spaces/tabs) right there where I pressed Tab. Just insert spaces/tab, DO NOT DO "smart"-indentation.
[optionally] When I press Shift+Tab, remove one indentation character from the beginning of the current line
[optionally] Do indent/unindent selected blocks.
The question is: Does a mode like this exist? If, what is the name of it?
I don't want to start discussion on "Why do I need this behavior?" and I do not need "smart" alternatives for reasons beyond this topic.
I just want a plain stupid mode...
Emacs has been there for ages. Someone somewhere at some point of time must have asked this question and probably written a mode for it.
I went through lots of "indentation-related" topics... nothing there. Everyone just insists on "you should obey Emacs, not Emacs should obey you".
Upvotes: 4
Views: 495
Reputation: 2409
There you go, I just wrote it: https://gist.github.com/mishoo/5487564
Upvotes: 4
Reputation: 20238
1. While in fundamental-mode
, you could rebind RET to newline-and-indent
(local-set-key (kbd "RET") 'newline-and-indent)
2. To make TAB insert tabulation/spaces instead of indenting, you should customize the tab-always-indent
variable :
(setq tab-always-indent nil)
To choose between tab and space indentation, customize the indent-tabs-mode
variable.
(setq indent-tabs-mode t) ;; for tab-based indentation
(setq indent-tabs-mode nil) ;; for space-based indentation
I don't know of any standard way of doing points 3. and 4., but it should not be too difficult to develop small custom functions to do this.
Upvotes: 2