*getbufinfo()*
getbufinfo([{dict}])
Get information about buffers as a List of Dictionaries.
Without an argument information about all the buffers is
returned.
When the argument is a |Dictionary| only the buffers matching
the specified criteria are returned. The following keys can
be specified in {dict}:
buflisted include only listed buffers.
bufloaded include only loaded buffers.
bufmodified include only modified buffers.
Otherwise, {buf} specifies a particular buffer to return
information for. For the use of {buf}, see |bufname()|
above. If the buffer is found the returned List has one item.
Otherwise the result is an empty list.
Each returned List item is a dictionary with the following
entries:
bufnr Buffer number.
changed TRUE if the buffer is modified.
changedtick Number of changes made to the buffer.
command TRUE if the buffer belongs to the
command-line window |cmdwin|.
hidden TRUE if the buffer is hidden.
lastused Timestamp in seconds, like
|localtime()|, when the buffer was
last used.
listed TRUE if the buffer is listed.
lnum Line number used for the buffer when
opened in the current window.
Only valid if the buffer has been
displayed in the window in the past.
If you want the line number of the
last known cursor position in a given
window, use |line()|: >vim
echo line('.', {winid})
<
linecount Number of lines in the buffer (only
valid when loaded)
loaded TRUE if the buffer is loaded.
name Full path to the file in the buffer.
signs List of signs placed in the buffer.
Each list item is a dictionary with
the following fields:
id sign identifier
lnum line number
name sign name
variables A reference to the dictionary with
buffer-local variables.
windows List of |window-ID|s that display this
buffer
Examples: >vim
for buf in getbufinfo()
echo buf.name
endfor
for buf in getbufinfo({'buflisted':1})
if buf.changed
" ....
endif
endfor
<
To get buffer-local options use: >vim
getbufvar({bufnr}, '&option_name')
<
Parameters: ~
• {dict} (`vim.fn.getbufinfo.dict?`)
Return: ~
(`vim.fn.getbufinfo.ret.item[]`)
getbufline({buf}, {lnum} [, {end}]) *getbufline()*
Return a |List| with the lines starting from {lnum} to {end}
(inclusive) in the buffer {buf}. If {end} is omitted, a
|List| with only the line {lnum} is returned. See
`getbufoneline()` for only getting the line.
For the use of {buf}, see |bufname()| above.
For {lnum} and {end} "$" can be used for the last line of the
buffer. Otherwise a number must be used.
When {lnum} is smaller than 1 or bigger than the number of
lines in the buffer, an empty |List| is returned.
When {end} is greater than the number of lines in the buffer,
it is treated as {end} is set to the number of lines in the
buffer. When {end} is before {lnum} an empty |List| is
returned.
This function works only for loaded buffers. For unloaded and
non-existing buffers, an empty |List| is returned.
Example: >vim
let lines = getbufline(bufnr("myfile"), 1, "$")
<
Parameters: ~
• {buf} (`integer|string`)
• {lnum} (`integer`)
• {end} (`integer?`)
Return: ~
(`string[]`)
getbufoneline({buf}, {lnum}) *getbufoneline()*
Just like `getbufline()` but only get one line and return it
as a string.
Parameters: ~
• {buf} (`integer|string`)
• {lnum} (`integer`)
Return: ~
(`string`)
getbufvar({buf}, {varname} [, {def}]) *getbufvar()*
The result is the value of option or local buffer variable