$defs = {
   "key1" => 1,       # indented correct with tab
       "key2" => 2,   # indented too much, should align with key1
       "key3" => 3,   # keeps indentation from here on

With regular perl-mode in Emacs 26.5 the indentation is "staggered" like above, where key2 and key3 are not aligned with key1 when tab is pressed, but should be. How to make perl-mode do that? (not cperl-mode).

  • Why do you not want to use cperl-mode?
    – nega
    Commented Mar 20, 2020 at 0:52
  • I would have to learn it to get the same behaviour and face, which I set up some time in 1995 and have forgotten all about, because it works. Commented Mar 20, 2020 at 7:52
  • 1
    Cool, I can understand that. I do recommend you give cperl-mode a try. Think of it as more of a superset of perl-mode. And, there's always emacs.SE to help smooth the transition.
    – nega
    Commented Mar 20, 2020 at 17:41

1 Answer 1


Try setting perl-continued-statement-offset.

(setq perl-continued-statement-offset 0)

See it's documentation (via Ctrl-H v):

perl-continued-statement-offset is a variable defined in ‘perl-mode.el’.
Its value is 4

  This variable is safe as a file local variable if its value
  satisfies the predicate ‘integerp’.

Extra indent for lines not starting new statements.

You can customize this variable.

You'll notice its (default) value is "4"; the number of spaces your "key2" is indented. If you change this while a perl-mode buffer is active you'll have to manually re-indent the code in that buffer. Setting his may negatively change other indentation, so keep an eye out.

  • Sure does .. gratitude. Cruisin' again, thanks. Commented Mar 20, 2020 at 7:50
  • Great! Feel free to accept that answer. 😉
    – nega
    Commented Mar 20, 2020 at 17:42
  • I tried to press the up arrow, but I am one of low repute. Commented Mar 21, 2020 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.