Let's say I make this code with bad formatting: is there an emacs command that can automatically fix indentation? I know this question has been asked a few times before, but all the answers I've seen seem very technical (I'm a CS noob).

(define (count-until x y list1)

    (define (iter list1 score) 
    (if (eq? (car list1) x)
    (iter (cdr list1) (+ score 1))
    (iter (cdr list1) score)))

    (iter list1 0))

1 Answer 1


Select the whole code (e.g. by pressing C-Space at the start and using cursor keys to get to the end) and run indent-region (bound to C-M-\ in my Emacs).

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.