How do I make equalprg match my custom indent settings? They are like:

let b:did_indent = 1
set expandtab       
set shiftwidth=2
set softtabstop=2

set autoindent

And they format the code to this (actually I have to add the 2 extra spaces myself):

(. fs (writeFile "test.txt" "some text" (fn [err]
  (. res(send (if err "error" "done")))

And when I use =, this is what I got:

(. fs (writeFile "test.txt" "some text" (fn [err]
                                         (. res(send (if err "error" "done")))

How do I keep the first form?

Also, would it be possible to add the leading spaces automatically then, because I suppose they would be scrapped?

  • This one holds a further requirement not edited into the duplicate.
    – wbogacz
    Oct 21, 2017 at 14:07
  • Is it acceptable to put (fn [err] ...) on the next line? I generally prefer function/lambda expressions in lisps to be aligned, which is probably what clojure's indentexpr is trying to do
    – D. Ben Knoble
    Dec 16, 2019 at 15:27

1 Answer 1


equalprg specifies an external program, there is no way for the external program to know your specific indenting settings, except for parsing your various configuration files.

In general it is better to go with the indentexpr setting, which can use various VimScript to perform your indentation (as well as call an external program).

Your Answer

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

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