Tested with vim --clean \<filename>.py, then did :filetype plugin on and :filetype plugin indent on. To make code look better, i wanted to write something like this for a dictionary:

test = {

However for some reason vim idents lines after test = { twice instead of once, including the closing }. What causes this, and how can it be fixed?

  • Take a look at :setlocal and keep an eye out for the indent-related ones. Those are the things you need to tweak (FWIW, the python indenter shipped with vim is pretty horrible; I just format with Black or similar.) :help indent.txt suggests :help indent-expression and the related filetype stuff, plus :help 30.3 – D. Ben Knoble Mar 24 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.