Skip to main content
Version: Next

writeSync

function writeSync(bufId): number;

Write (save) buffer's text contents to local filesystem synchronizely.

Parameters​

ParameterTypeDescription

bufId

number

The buffer's ID that you want to write to filesystem.

Returns​

number

It returns a positive integer to indicate how many bytes have been written to the file, if written successfully.

Throws​

Throws TypeError if the parameter is invalid, or Error if failed to write buffer to file system.

Example​

const bufId = Rsvim.buf.currentBufferId();
try {
const bytes = Rsvim.buf.writeSync(bufId);
Rsvim.cmd.echo(`Buffer ${bufId} has been saved, ${bytes} bytes written`);
} catch (e) {
Rsvim.cmd.echo(`Error: failed to save buffer ${bufId}, exception: ${e}`);
}