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?

4
  • 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, 2023 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, 2023 at 16:23
  • Does this answer your question? Dumb indentation
    – Drew
    Sep 27, 2023 at 16:24
  • 1
    See also emacs.stackexchange.com/q/31094, as another possible duplicate, depending on what you're doing and what you want to do.
    – Drew
    Sep 27, 2023 at 16:25

1 Answer 1

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.

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.