Module Vim.Buffer
type t
= Vim__.Native.buffer
val openFile : string -> t
openFile(path)
opens a file, sets it as the active buffer, and returns a handle to the buffer.
val getFilename : t -> string option
getFileName(buffer)
returns the full file path of the bufferbuffer
val getVersion : t -> int
getVersion(buffer)
returns the latest changedtick of the bufferbuffer
.The changedtick gets updated with each modification to the buffer
val isModified : t -> bool
isModified(buffer)
returnstrue
if the buffer has been modified since the last save,false
otherwise.
val getLineCount : t -> int
getLineCount(buffer)
returns the number of lines in the buffer.
val getLine : t -> int -> string
getline(buffer, line)
returns the text content at the one-based line numberline
for bufferbuffer
.
val getId : t -> int
getId(buffer)
returns the id of bufferbuffer
;
val getById : int -> t option
getById(id)
returns a buffer if one is available with the specified id if it exists, otherwiseNone
.
val getCurrent : unit -> t
getCurrent()
returns the currently active buffer.
val setCurrent : t -> unit
setCurrent(buffer)
sets the active buffer tobuffer
.This will trigger dispatching of autocommands, like
BufEnter
.
val onEnter : Vim__.Listeners.bufferListener -> Vim__.Event.unsubscribe
onEnter(f)
adds a listenerf
that is called whenever a new buffer is entered.This is more reliable than autocommands, as it will dispatch in any case the buffer is changed, even in cases where
BufEnter
would not be dispatched.Returns a function that can be called to unsubscribe.
val onUpdate : Vim__.Listeners.bufferUpdateListener -> Vim__.Event.unsubscribe
onUpdate(f)
adds a listenerf
that is called whenever a buffer is modified.Returns a function that can be called to unsubscribe.