The option termwinsize cannot be accessed from Python 3.


python3 << EOD

import vim

for window in vim.windows:
    if (window.buffer.options['buftype'] == b'terminal'):
        window.buffer.options['termwinsize'] = '10x0'


Expected Result


Actual Result

KeyError: 'termwinsize'

Is this an expected behavior or a bug?

(:set termwinsize=10x0 succeeds. The options cannot be accessed only from Python 3.)

  • 3
    Try window.options['termwinsize']
    – husB
    Commented Jun 7, 2021 at 4:19

1 Answer 1


It is actually the expected behavior, although that is clearly not what was intended. The key is that 'termwinsize' is "local to window", whereas 'buftype' is "local to buffer".

There is a slight --- but important --- distinction between "window" and "buffer". :h windows.txt explains this distinction in great detail. But briefly, a window is a view of a buffer.

Therefore, when accessing these options via the python interface, one would use window.options['termwinsize'], and window.buffer.options['buftype'] respectively.

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.