writeSync
function writeSync(bufId): number;
Write (save) buffer's text contents to local filesystem synchronizely.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| 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}`);
}