0

Not a duplicate of Emacs version 24.4: New obnoxious loss of indentation on hitting RETURN

Turning off electric-indent-mode doesn't solve the issues I am having. Notice that that question doesn't have an accepted answer.

Original question:

Currently using Emacs version 24.5.1 on Windows 7, and the changed behaviour of C-j is extremely irritating. I am sure the designers must have thought it a good idea, but I don't.

Is there any way to get back the behaviour of C-j from older versions? More specifically, I am thinking of v21.x (installed it a few years back on my Mac).

Explanation:

This is what I get in my older version (imagine hitting C-j at the end of each line:

Line 01:    Some text.
Line 02:    Some more text.
Line 03:
Line 04:    Yet more text (notice the indentation stays the same despite
Line 05:    the empty line in-between).

In 24.5.1 by default I get (again imagine hitting C-j at the end of each line):

Line 01:    Some text.
Line 02:    Some more text.
Line 03:
Line 04: Yet more text (notice the indentation goes to zero because of
Line 05: the empty line in-between).

The key binding C-j runs newline-and-indent in Emacs 24.5.1.

Community
  • 1
  • 1
markvgti
  • 4,321
  • 7
  • 40
  • 62
  • Do you have an older version where you can just copy the functions over to your new `.emacs` file and change the keyboard shortcut to the slightly modified name for the older version? – lawlist Aug 05 '15 at 06:47
  • @lawlist I've added an explanation above. Hopefully it's understandable :-). – markvgti Aug 05 '15 at 13:28

1 Answers1

0

You might want to use the built in function default-indent-new-line. Try it by M-x default-indent-new-line. At least in text-mode it does what you describe.

To overwrite C-j in every mode you can just use this snippet in your .emacs file.

(global-set-key (kbd "C-j")  'default-indent-new-line)
ayckoster
  • 6,707
  • 6
  • 32
  • 45