:help ft-python-indent lists the following command:

let g:python_indent.disable_parentheses_indenting = 1

but when I try to use that in my config I am getting the error message

E121: Undefined variable g:python_indent

I am surprised that the variable name contains a dot and judging from the error message it seems like vim indeed considers the dot part the end of the variable name.

I have found the code where the variable is used in /usr/share/vim/vim90/autoload/python.vim:

if g:python_indent.disable_parentheses_indenting == 1

As far as I remember a dot is used to concatenate strings so I thought that maybe these are two variables and I can use either one to enable this feature. So I have tried:

let disable_parentheses_indenting = 1

That does not give an error but does not enable the feature either.

Probably because it's a local variable.

I don't want to set the first variable, g:python_indent because that is used for other features, too, which I don't want to change. But then again it seems pretty clear in the help that this is supposed to be a single variable.

What is going on here?

How can I enable this feature?

I am using vim 9.0.

1 Answer 1


The . syntax is an alternative to access a dictionary value associated to a key.

let g:python_indent.disable_parentheses_indenting = 1

Is equivalent to:

let g:python_indent['disable_parentheses_indenting'] = 1

To define it you first declare g:python_indent as a dictionary

let g:python_indent = {}
let g:python_indent.disable_parentheses_indenting = 1

Or if you want to be sure not to empty an existing dictionary

if !exists('g:python_indent')
  let g:python_indent = {}
let g:python_indent.disable_parentheses_indenting = 1
  • 1
    thank you so much, that explains it! btw I think there is a typo in your answer, it should be only one = in the let statement.
    – jakun
    Oct 9, 2022 at 16:54
  • Thanks for the feedback. I'm glad I have been able to help you. I corrected the typo ;-) Oct 9, 2022 at 16:55
  • 1
    thank you. Actually that let statement appears three more times in the answer :)
    – jakun
    Oct 9, 2022 at 16:57
  • 2
    Or if you want it on a single line @jakun: let g:python_indent = #{disable_parentheses_indenting: 1}. Or with checking if it already exists (bit complicated): let g:python_indent = get(g:, 'python_indent', {})->extend(#{disable_parentheses_indenting: 1}). Oct 9, 2022 at 17:57

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.