Skip to main content
Version: 0.1.2

RsvimOpt

The Rsvim.opt global object for global editor options.

Example

// Create a alias to 'Rsvim.opt'.
const opt = Rsvim.opt;

Accessors

expandTab

Get Signature

get expandTab(): boolean;

Get the expand-tab option. Local to buffer.

When in insert mode, inserts spaces (ASCII 32) instead of a horizontal tab (ASCII 9).

See shiftWidth to get the number of spaces when inserting.

Default Value

false

Example
// Get the 'expand-tab' option.
const value = Rsvim.opt.expandTab;
Returns

boolean

Set Signature

set expandTab(value): void;

Set the expand-tab option.

Throws

Throws Error if value is not a boolean value.

Example
// Set the 'expand-tab' option.
Rsvim.opt.expandTab = true;
Parameters
ParameterTypeDescription

value

boolean

The expand-tab option.

Returns

void


fileEncoding

Get Signature

get fileEncoding(): "utf-8";

Get the file-encoding option. Local to buffer.

Sets the character encoding for the file of this buffer. This will determine which character encoding is used when RSVIM read/write a file from file system.

warning

For now, only utf-8 encoding is supported.

Default Value

"utf-8"

Example
// Get the 'file-encoding' option.
const value = Rsvim.opt.fileEncoding;
Returns

"utf-8"

Set Signature

set fileEncoding(value): void;

Set the file-encoding option.

Throws

Throws Error if value is not a valid option.

Example
// Set the 'file-encoding' option.
Rsvim.opt.fileEncoding = "utf-8";
Parameters
ParameterTypeDescription

value

"utf-8"

The file-encoding option.

Returns

void


fileFormat

Get Signature

get fileFormat(): "dos" | "unix" | "mac";

Get the file-format option. Local to buffer.

Sets the line end for the file of this buffer. There are 3 kinds of line end:

note

In fact it should be named to "line-end", it is called "file-format" just to be consistent with Vim's fileformat option.

For this API, it has below options:

  • "dos": equivalent to CRLF line end.
  • "unix": equivalent to LF line end.
  • "mac": equivalent to CR line end. You would never use it today.
Default Value

"dos" for Windows/MS-DOS, "unix" for Linux/Unix/MacOS.

Example
// Get the 'file-format' option.
const value = Rsvim.opt.fileFormat;
Returns

"dos" | "unix" | "mac"

Set Signature

set fileFormat(value): void;

Set the file-format option.

Throws

Throws Error if value is not a valid option.

Example
// Set the 'file-format' option.
Rsvim.opt.fileFormat = "unix";
Parameters
ParameterTypeDescription

value

"dos" | "unix" | "mac"

The file-format option.

Returns

void


lineBreak

Get Signature

get lineBreak(): boolean;

Get the line-break option. This options is also known as word wrap. Local to window.

If true, Vim will wrap long lines by a word boundary rather than at the last character that fits on the screen. It only affects the way the file is displayed, not its contents.

This option is not used when the wrap option is false.

Default Value

false

Example
// Get the 'lineBreak' option.
const value = Rsvim.opt.lineBreak;
Returns

boolean

Set Signature

set lineBreak(value): void;

Set the line-break option.

Throws

Throws Error if value is not a boolean value.

Example
// Set the 'lineBreak' option.
Rsvim.opt.lineBreak = true;
Parameters
ParameterTypeDescription

value

boolean

The line-break option.

Returns

void


shiftWidth

Get Signature

get shiftWidth(): number;

Get the shift-width option. Local to buffer.

When expandTab is true, the number of spaces that is used when inserts a horizontal tab (ASCII 9).

When expandTab is false, this option is not been used.

Default Value

8

Example
// Get the 'shift-width' option.
const value = Rsvim.opt.shiftWidth;
Returns

number

Set Signature

set shiftWidth(value): void;

Set the expand-tab option. This value should be between [1,255].

Throws

Throws Error if value is not a positive integer that between [1,255].

Example
// Set the 'shift-width' option.
Rsvim.opt.shiftWidth = 4;
Parameters
ParameterTypeDescription

value

number

The expand-tab option.

Returns

void


tabStop

Get Signature

get tabStop(): number;

Get the tab-stop option. This option is also known as tab-size. Local to buffer.

This option changes how text is displayed.

Defines how many columns (on the terminal) used to display the horizontal tab (ASCII 9). This value should be between [1,255].

Default Value

8

Example
// Get the 'tab-stop' option.
const value = Rsvim.opt.tabStop;
Returns

number

Set Signature

set tabStop(value): void;

Set the tab-stop option.

Throws

Throws Error if value is not a positive integer that between [1,255].

Example
// Set the 'tab-stop' option.
Rsvim.opt.tabStop = 4;
Parameters
ParameterTypeDescription

value

number

The tab-stop option. It only accepts an integer between [1,255].

Returns

void


wrap

Get Signature

get wrap(): boolean;

Get the wrap option. This option is also known as line wrap. Local to window.

This option changes how text is displayed.

When true, lines longer than the width of the window will wrap and displaying continues on the next line. When false lines will not wrap and only part of long lines will be displayed. When the cursor is moved to a part that is not shown, the screen will scroll horizontally.

The line will be broken in the middle of a word if necessary. See lineBreak to get the break at a word boundary.

Default Value

true

Example
// Get the 'wrap' option.
const value = Rsvim.opt.wrap;
Returns

boolean

Set Signature

set wrap(value): void;

Set the wrap option.

Throws

Throws Error if value is not a boolean value.

Example
// Set the 'wrap' option.
Rsvim.opt.wrap = true;
Parameters
ParameterTypeDescription

value

boolean

The wrap option.

Returns

void