1

Demonstration of the problem:

# starting point:
function hello_world {
    _somecommand_ parameter '
    | <--- point/cursor is here on step one
    '
}

the next step (I take issue with):

function hello_world { somecommand parameter ' TAB | <--- point/cursor is now here on step two alligned right under the beginning of awk. that's not a multiple of four and it "skipped" several multiples. ' }

the next step (what I actually wanted to happen):

function hello_world { somecommand parameter ' TAB | <--- I want the cursor to be strictly just 4 spaces to the right of TAB ' }

Legend:

| == the cursor/point

TAB == press the TAB key at that position

There seems to be some mode I'm not aware of that auto-aligns words vertically in some situations, where in fact I'd like my indentation to be predictable and strictly in multiples of whatever tabstop I have defined (I prefer four, and with no "skips").

How to achieve this?

Drew
  • 77,472
  • 10
  • 114
  • 243
Paxsali
  • 181
  • 5
  • What's the value of variable tab-width in the buffer in question? This is a buffer-local variable. Do you see the same thing if you start Emacs using emacs -Q (no init file)? If not, bisect your init file to find the culprit. – Drew Sep 27 '23 at 16:18
  • What is key TAB bound to in the mode you're in? In programming modes it's typically bound to a command that indents according to the style defined for that mode - it doesn't indent a fixed tab-width amount. – Drew Sep 27 '23 at 16:23
  • Does this answer your question? Dumb indentation – Drew Sep 27 '23 at 16:24
  • 1
    See also https://emacs.stackexchange.com/q/31094, as another possible duplicate, depending on what you're doing and what you want to do. – Drew Sep 27 '23 at 16:25

1 Answers1

1
;;; some spacemacs default I don't like and I
;;; don't know from which layer it comes from:
;; (setq indent-line-function 'smie-indent-line)

;;; instead use this for achieve "predictable indents":
(setq indent-line-function 'insert-tab)

;;; or
;; (setq-local indent-line-function 'insert-tab)

I figured out that my indent-line-function was some special function I don't recognize.

Setting it to insert-tab does exactly what I was looking for.

Thanks for the links to the other questions @Drew.

Paxsali
  • 181
  • 5