1

The option termwinsize cannot be accessed from Python 3.

Input

python3 << EOD

import vim

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

EOD

Expected Result

Success.

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.)

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

1 Answer 1

2

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 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.