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

val getVersion : t -> int

getVersion(buffer) returns the latest changedtick of the buffer buffer.

The changedtick gets updated with each modification to the buffer

val isModified : t -> bool

isModified(buffer) returns true 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 number line for buffer buffer.

val getId : t -> int

getId(buffer) returns the id of buffer buffer;

val getById : int -> t option

getById(id) returns a buffer if one is available with the specified id if it exists, otherwise None.

val getCurrent : unit -> t

getCurrent() returns the currently active buffer.

val setCurrent : t -> unit

setCurrent(buffer) sets the active buffer to buffer.

This will trigger dispatching of autocommands, like BufEnter.

val onEnter : Vim__.Listeners.bufferListener -> Vim__.Event.unsubscribe

onEnter(f) adds a listener f 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 listener f that is called whenever a buffer is modified.

Returns a function that can be called to unsubscribe.