RsvimOpt
The Rsvim.opt global object for global editor options. These options will change the editor's behavior
and suit user's personal habits.
There are 3 kinds of editor option:
- Global options: Options that are global that you use one value for all Rsvim component instances such as buffer, window, statusline, etc. When you change the option, it will take effect immediately and affect all existing instances.
- Local options: Options that only apply to one component instance, each instance has its own copy of this option, thus each can have its own value. This allow you to set an option in one instance, without modifying other instances.
- Global local options: Options that are global, and will be copy to a newly created Rsvim component instance. A global-local-option always has its corresponding local-option. When you change the option, it only will apply to the newly created instances, but cannot modify existing instances.
Example
// Create a alias to 'Rsvim.opt'.
const opt = Rsvim.opt;
Accessors
expandTab
Get Signature
get expandTab(): boolean;
Get the expand-tab option. Global 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 TypeError if value is not a boolean.
Example
// Set the 'expand-tab' option.
Rsvim.opt.expandTab = true;
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The expand-tab option. |
Returns
void
fileEncoding
Get Signature
get fileEncoding(): "utf-8";
Get the file-encoding option. Global 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.
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 RangeError if value is an invalid option.
Example
// Set the 'file-encoding' option.
Rsvim.opt.fileEncoding = "utf-8";
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The file-encoding option. |
Returns
void
fileFormat
Get Signature
get fileFormat(): "dos" | "unix" | "mac";
Get the file-format option. Global local to buffer.
Sets the line end for the buffer. There are 3 kinds of line end:
CRLF: used by Windows.LF: used by Linux and Unix (include MacOS).CR: used by classic MacOS.
Today's Mac also uses LF as line end, you should never use CR any more.
In fact this option should be named to "line-end", "file-format" is just to be consistent with Vim's fileformat.
For this option, it has below choices:
"dos": equivalent toCRLFline end."unix": equivalent toLFline end."mac": equivalent toCRline end.
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 RangeError if value is an invalid option.
Example
// Set the 'file-format' option.
Rsvim.opt.fileFormat = "unix";
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| 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. Global 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 TypeError if value is not a boolean.
Example
// Set the 'lineBreak' option.
Rsvim.opt.lineBreak = true;
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The line-break option. |
Returns
void
shiftWidth
Get Signature
get shiftWidth(): number;
Get the shift-width option. Global 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. It only accepts an integer between [1,255], if the value is out of range, it will be bound to this range.
Throws
Throws TypeError if value is not an integer.
Example
// Set the 'shift-width' option.
Rsvim.opt.shiftWidth = 4;
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| 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. Global 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. It only accepts an integer between [1,255], if the value is out of range, it will be bound to this range.
Throws
Throws TypeError if value is not an integer.
Example
// Set the 'tab-stop' option.
Rsvim.opt.tabStop = 4;
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The tab-stop option. |
Returns
void
wrap
Get Signature
get wrap(): boolean;
Get the wrap option. This option is also known as line wrap. Global 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 TypeError if value is not a boolean.
Example
// Set the 'wrap' option.
Rsvim.opt.wrap = true;
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The wrap option. |
Returns
void