Vim: number of total buffers

buffervim

in vim, with

:buffers

I get the number of all buffers
the same with

:ls

, but
how I can get the total number of buffers ?

Best Answer

Same idea than Heptite's solution, but as a one liner. Many other things may be done this way: get the name of the buffer (thanks to map), wipeout buffers that match a pattern, https://stackoverflow.com/questions/2974192/how-can-i-pare-down-vims-buffer-list-to-only-include-active-buffers/2974600#2974600n etc.

echo len(filter(range(1, bufnr('$')), 'buflisted(v:val)'))
Related Question