Primitive indentation in Emacs

Does Emacs have a simple primitive indentation mode that will do the following:

  • When I go to a new line (Hit Enter), copy any white space used for indenting for the above line

  • When I press Tab, we insert characters (and) that can be customized (spaces / tabs) right where I hit Tab. Just insert spaces / tab, DO NOT do smart -intext.

  • [optional] When I press Shift+ Tab, I remove one indent character from the beginning of the current line

  • [optional] Make the indentation blocks selected / unindent.

The question is: is there such a regime? If what is his name?

I don't want to start a discussion "Why do I need this behavior?" and I don't need smart alternatives for reasons beyond the scope of this topic.

I just want a simple stupid mode ...

Emacs has been around for ages. Someone, somewhere at some point, must have asked this question and probably wrote a mode for it.

I have looked through a lot of topics related to indentation ... nothing there. Everybody just insists, "You should obey Emacs, not Emacs should obey you."


source to share

2 answers

There you go, I just wrote this:



1. In fundamental-mode

you can rebuild RETonnewline-and-indent

(local-set-key (kbd "RET") 'newline-and-indent)


2. To make TABinsert tables / spaces instead of indentation, you must set up a variable tab-always-indent


(setq tab-always-indent nil)


To choose between tab and space insertions, adjust the variable indent-tabs-mode


(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 shouldn't be too hard to develop small custom functions to do this ..



All Articles