I want to unlist a terminal buffer that I open in a popup window. Here are my attempts:

var buf_no = term_start(&shell, {'term_name': 'foo', 'hidden': 1, 'term_finish': 'close'})
setbufvar(bufname(buf_no), 'buflisted', 0)


   var buf_no = term_start(os_shell, {'term_name': my_term_name, 'hidden': 1, 'term_finish': 'close'})
    win_execute(bufwinid(buf_no), 'setlocal nobuflisted')

but it does not work. I also check if there is some unlisted option in :h term_start() but it does not exists.

1 Answer 1


With the following code:

setbufvar(bufname(buf_no), 'buflisted', 0)

you are defining a buffer-local variable, b:buflisted with value 0, which is pointless because nothing is using it.

:help 'buflisted' is an option, not a variable. To change the value of an option, use the &option notation:

setbufvar(bufname(buf_no), '&buflisted', 0)

as per :help setbufvar():

        :call setbufvar(1, "&mod", 1)

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.