import * as denopsStd from "https://deno.land/x/denops_std@v4.1.5/function/mod.ts";
A module to provide functions of Vim and Neovim native functions.
import { Denops } from "../mod.ts";
import * as fn from "../function/mod.ts";
export async function main(denops: Denops): Promise<void> {
// fn holds functions exists in both Vim and Neovim
console.log(fn.or(denops, 0, 1));
}
See vim/mod.ts
or nvim/mod.ts
if you need Vim or Neovim specific functions.
Functions
f abs | Return the absolute value of {expr}. When {expr} evaluates to
a |
f acos | Return the arc cosine of {expr} measured in radians, as a
|
f add | Append the item {expr} to |
f and | Bitwise AND on the two arguments. The arguments are converted
to a number. A List, Dict or Float argument causes an error.
Also see |
When {text} is a | |
Like | |
f argc | The result is the number of files in the argument list. See
|
The result is the current index in the argument list. 0 is
the first file. argc() - 1 is the last one. See | |
Return the argument list ID. This is a number which
identifies the argument list being used. Zero is used for the
global argument list. See | |
f argv | The result is the **{nr}**th file in the argument list. See
|
f asin | Return the arc sine of {expr} measured in radians, as a |
Assert if | |
Assert if | |
f atan | Return the principal value of the arc tangent of {expr}, in
the range [-pi/2, +pi/2] radians, as a |
Return the arc tangent of {expr1} / {expr2}, measured in
radians, as a | |
Put up a file requester. This only works when "has("browse")"
returns | |
Put up a directory requester. This only works when
"has("browse")" returns | |
Add a buffer to the buffer list with name {name} (must be a String). If a buffer for file {name} already exists, return that buffer number. Otherwise return the buffer number of the newly created buffer. When {name} is an empty string then a new buffer is always created. The buffer will not have 'buflisted' set and not be loaded yet. To add some text to the buffer use this: let bufnr = bufadd('someName') call bufload(bufnr) call setbufline(bufnr, 1, ['some', 'text']) Returns 0 on error. Can also be used as a |method|: let bufnr = 'somename'->bufadd() | |
The result is a Number, which is |TRUE| if a buffer called {buf} exists. If the {buf} argument is a number, buffer numbers are used. | |
The result is a Number, which is |TRUE| if a buffer called {buf} exists and is listed (has the 'buflisted' option set). The {buf} argument is used like with |bufexists()|. | |
Ensure the buffer {buf} is loaded. When the buffer name refers to an existing file then the file is read. Otherwise the buffer will be empty. If the buffer was already loaded then there is no change. If the buffer is not related to a file the no file is read (e.g., when 'buftype' is "nofile"). If there is an existing swap file for the file of the buffer, there will be no dialog, the buffer will be loaded anyway. The {buf} argument is used like with |bufexists()|. | |
The result is a Number, which is |TRUE| if a buffer called {buf} exists and is loaded (shown in a window or hidden). The {buf} argument is used like with |bufexists()|. | |
The result is the name of a buffer. Mostly as it is displayed
by the | |
The result is the number of a buffer, as it is displayed by
the | |
The result is a Number, which is the |window-ID| of the first window associated with buffer {buf}. For the use of {buf}, see |bufname()| above. If buffer {buf} doesn't exist or there is no such window, -1 is returned. Example: | |
Like |bufwinid()| but return the window number instead of the |window-ID|. If buffer {buf} doesn't exist or there is no such window, -1 is returned. Example: | |
Return the line number that contains the character at byte count {byte} in the current buffer. This includes the end-of-line character, depending on the 'fileformat' option for the current buffer. The first character has byte count one. Also see |line2byte()|, |go| and |:goto|. | |
Return byte index of the {nr}'th character in the String
{expr}. Use zero for the first character, it then returns
zero.
If there are no multibyte characters the returned value is
equal to {nr}.
Composing characters are not counted separately, their byte
length is added to the preceding base character. See
| |
Like byteidx(), except that a composing character is counted as a separate character. Example: | |
f call | Call function {func} with the items in |
f ceil | Return the smallest integral value greater than or equal to
{expr} as a |
Return the number of the most recent change. This is the same
number as what is displayed with | |
Return Number value of the first char in {string}. Examples: | |
Return the character class of the first character in {string}.
The character class is one of:
0 blank
1 punctuation
2 word character
3 emoji
other specific Unicode class
The class is used in patterns and word motions.
Returns 0 if {string} is not a | |
Same as | |
Return the character index of the byte at {idx} in {string}.
The index of the first character is zero.
If there are no multibyte characters the returned value is
equal to {idx}.
When {countcc} is omitted or | |
Change the current working directory to {dir}. The scope of
the directory change depends on the directory of the current
window:
- If the current window has a window-local directory
( | |
Get the amount of indent for line {lnum} according the C
indenting rules, as with 'cindent'.
The indent is counted in spaces, the value of 'tabstop' is
relevant. {lnum} is used just like in | |
Clears all matches previously defined for the current window
by | |
f col | The result is a Number, which is the byte index of the column position given with {expr}. The accepted positions are: . the cursor position $ the end of the cursor line (the result is the number of bytes in the cursor line plus one) 'x position of mark x (if the mark is not set, 0 is returned) v In Visual mode: the start of the Visual area (the cursor is the end). When not in Visual mode returns the cursor position. Differs from |'<| in that it's updated right away. Additionally {expr} can be [lnum, col]: a |List| with the line and column number. Most useful when the column is "$", to get the last column of a specific line. When "lnum" or "col" is out of range then col() returns zero. To get the line number use |line()|. To get both use |getpos()|. For the screen column position use |virtcol()|. For the character position use |charcol()|. Note that only marks in the current file can be used. Examples: col(".") column of cursor col("$") length of cursor line plus one col("'t") column of mark t col("'" .. markname) column of mark markname The first column is 1. Returns 0 if {expr} is invalid. For an uppercase mark the column may actually be in another buffer. For the cursor position, when 'virtualedit' is active, the column is one higher if the cursor is after the end of the line. This can be used to obtain the column in Insert mode: :imap :let save_ve = &ve <C-O>:set ve=all <C-O>:echo col(".") .. "\n" \let &ve = save_ve GetPos()->col() |
Set the matches for Insert mode completion.
Can only be used in Insert mode. You need to use a mapping
with CTRL-R = (see | |
Add {expr} to the list of matches. Only to be used by the
function specified with the 'completefunc' option.
Returns 0 for failure (empty string or out of memory),
1 when the match was added, 2 when the match was already in
the list.
See | |
Check for a key typed while looking for completion matches.
This is to be used when looking for matches takes some time.
Returns | |
Returns a | |
confirm() offers the user a dialog, from which a choice can be
made. It returns the number of the choice. For the first
choice this is 1.
Note: confirm() is only supported when compiled with dialog
support, see | |
f copy | Make a copy of {expr}. For Numbers and Strings this isn't
different from using {expr} directly.
When {expr} is a |
f cos | Return the cosine of {expr}, measured in radians, as a |
f cosh | Return the hyperbolic cosine of {expr} as a |
Return the number of times an item with value {expr} appears
in | |
Checks for the existence of a | |
Positions the cursor at the column (byte count) {col} in the line {lnum}. The first column is one. | |
Specifically used to interrupt a program being debugged. It
will cause process {pid} to get a SIGTRAP. Behavior for other
processes is undefined. See | |
Make a copy of {expr}. For Numbers and Strings this isn't
different from using {expr} directly.
When {expr} is a | |
Without {flags} or with {flags} empty: Deletes the file by the name {fname}. | |
Delete lines {first} to {last} (inclusive) from buffer {buf}. If {last} is omitted then delete line {first} only. On success 0 is returned, on failure 1 is returned. | |
Returns | |
Returns the number of filler lines above line {lnum}. These are the lines that were inserted at this point in another diff'ed window. These filler lines are shown in the display but don't exist in the buffer. {lnum} is used like with |getline()|. Thus "." is the current line, "'m" mark m, etc. Returns 0 if the current window is not in diff mode. | |
Returns the highlight ID for diff mode at line {lnum} column
{col} (byte index). When the current line does not have a
diff change zero is returned.
{lnum} is used like with | |
Return the digraph of {chars}. This should be a string with exactly two characters. If {chars} are not just two characters, or the digraph of {chars} does not exist, an error is given and an empty string is returned. | |
Return a list of digraphs. If the {listall} argument is given and it is TRUE, return all digraphs, including the default digraphs. Otherwise, return only user-defined digraphs. | |
Add digraph {chars} to the list. {chars} must be a string
with two characters. {digraph} is a string with one UTF-8
encoded character.
Be careful, composing characters are NOT ignored. This
function is similar to | |
Similar to | |
Return the Number 1 if {expr} is empty, zero otherwise.
| |
Ensure if | |
Ensure if | |
Return all of environment variables as dictionary. You can check if an environment variable exists like this: | |
Escape the characters in {chars} that occur in {string} with a backslash. Example: | |
Evaluate {string} and return the result. Especially useful to
turn the result of | |
Returns 1 when inside an event handler. That is that Vim got interrupted while waiting for the user to type a character, e.g., when dropping a file on Vim. This means interactive commands cannot be used. Otherwise zero is returned. | |
This function checks if an executable with the name {expr}
exists. {expr} must be the name of the program without any
arguments.
executable() uses the value of $PATH and/or the normal
searchpath for programs.
On MS-Windows the ".exe", ".bat", etc. can optionally be
included. Then the extensions in $PATHEXT are tried. Thus if
"foo.exe" does not exist, "foo.exe.bat" can be found. If
$PATHEXT is not set then ".com;.exe;.bat;.cmd" is used. A dot
by itself can be used in $PATHEXT to try using the name
without an extension. When 'shell' looks like a Unix shell,
then the name is also tried without adding an extension.
On MS-Windows it only checks if the file exists and is not a
directory, not if it's really executable.
On MS-Windows an executable in the same directory as Vim is
normally found. Since this directory is added to $PATH it
should also work to execute it | |
Execute an Ex command or commands and return the output as a string. {command} can be a string or a List. In case of a List the lines are executed one by one. This is equivalent to: | |
If {expr} is an executable and is either an absolute path, a relative path or found in $PATH, return the full path. Note that the current directory is used when {expr} starts with "./", which may be a problem for Vim: | |
The result is a Number, which is |TRUE| if {expr} is defined, zero otherwise. | |
f exp | Return the exponential of {expr} as a |
Expand wildcards and the following special keywords in {string}. 'wildignorecase' applies. | |
Expand special items in String {string} like what is done for
an Ex command such as | |
{expr1} and {expr2} must be both | |
Characters in {string} are queued for processing as if they come from a mapping or were typed by the user. | |
The result is a Number, which is | |
The result is a Number, which is 1 when a file with the name {file} exists, and can be written. If {file} doesn't exist, or is not writable, the result is 0. If {file} is a directory, and we can write to it, the result is 2. | |
{expr1} must be a | |
Find directory {name} in {path}. Supports both downwards and
upwards recursive directory searches. See | |
Just like | |
Flatten {list} up to {maxdepth} levels. Without {maxdepth}
the result is a | |
Convert {expr} to a Number by omitting the part after the
decimal point.
{expr} must evaluate to a | |
Return the largest integral value less than or equal to
{expr} as a | |
f fmod | Return the remainder of {expr1} / {expr2}, even if the
division is not representable. Returns {expr1} - i * {expr2}
for some integer i such that if {expr2} is non-zero, the
result has the same sign as {expr1} and magnitude less than
the magnitude of {expr2}. If {expr2} is zero, the value
returned is zero. The value returned is a |
Escape {string} for use as file name command argument. All
characters that have a special meaning, such as '%' and '|'
are escaped with a backslash.
For most systems the characters escaped are
| |
Modify file name {fname} according to {mods}. {mods} is a
string of characters like it is used for file names on the
command line. See | |
The result is a Number. If the line {lnum} is in a closed
fold, the result is the number of the first line in that fold.
If the line {lnum} is not in a closed fold, -1 is returned.
{lnum} is used like with | |
The result is a Number. If the line {lnum} is in a closed
fold, the result is the number of the last line in that fold.
If the line {lnum} is not in a closed fold, -1 is returned.
{lnum} is used like with | |
The result is a Number, which is the foldlevel of line {lnum}
in the current buffer. For nested folds the deepest level is
returned. If there is no fold at line {lnum}, zero is
returned. It doesn't matter if the folds are open or closed.
When used while updating folds (from 'foldexpr') -1 is
returned for lines where folds are still to be updated and the
foldlevel is unknown. As a special case the level of the
previous line is usually available.
{lnum} is used like with | |
Returns a String, to be displayed for a closed fold. This is
the default function used for the 'foldtext' option and should
only be called from evaluating 'foldtext'. It uses the
| |
Returns the text that is displayed for the closed fold at line
{lnum}. Evaluates 'foldtext' in the appropriate context.
When there is no closed fold at {lnum} an empty string is
returned.
{lnum} is used like with | |
Get the full command name from a short abbreviated command
name; see | |
Just like | |
Return a | |
Cleanup unused | |
f get | Get item {idx} from |
Get information about buffers as a List of Dictionaries. | |
Return a |List| with the lines starting from {lnum} to {end} (inclusive) in the buffer {buf}. If {end} is omitted, a |List| with only the line {lnum} is returned. | |
The result is the value of option or local buffer variable
{varname} in buffer {buf}. Note that the name without "b:"
must be used.
The {varname} argument is a string.
When {varname} is empty returns a | |
Returns the | |
Get a single character from the user or input stream.
If [expr] is omitted, wait until a character is available.
If [expr] is 0, only get a character when one is available.
Return zero otherwise.
If [expr] is 1, only check if a character is available, it is
not consumed. Return zero if no character available.
If you prefer always getting a string use | |
The result is a Number which is the state of the modifiers for the last obtained character with getchar() or in another way. These values are added together: 2 shift 4 control 8 alt (meta) 16 meta (when it's different from ALT) 32 mouse double click 64 mouse triple click 96 mouse quadruple click (== 32 + 64) 128 command (Macintosh only) Only the modifiers that have not been included in the character itself are obtained. Thus Shift-a results in "A" without a modifier. Returns 0 if no modifiers are used. | |
Get the position for String {expr}. Same as | |
Return the current character search information as a {dict} with the following entries: | |
Get a single character from the user or input stream as a
string.
If [expr] is omitted, wait until a character is available.
If [expr] is 0 or false, only get a character when one is
available. Return an empty string otherwise.
If [expr] is 1 or true, only check if a character is
available, it is not consumed. Return an empty string
if no character is available.
Otherwise this works like | |
Return the type of the current command-line completion.
Only works when the command line is being edited, thus
requires use of | |
Return the current command-line. Only works when the command
line is being edited, thus requires use of | |
Return the position of the cursor in the command line as a
byte count. The first column is 1.
Only works when editing the command line, thus requires use of
| |
Return the screen position of the cursor in the command line
as a byte count. The first column is 1.
Instead of | |
Return the current command-line type. Possible return values
are:
: normal Ex command
> debug mode command | |
Return the current | |
Return a list of command-line completion matches. The String {type} argument specifies what for. The following completion types are supported: | |
Get the position of the cursor. This is like getpos('.'), but includes an extra "curswant" item in the list: [0, lnum, col, off, curswant] ~ The "curswant" number is the preferred column when moving the cursor vertically. After |$| command it will be a very large number equal to |v:maxcol|. Also see |getcursorcharpos()| and |getpos()|. The first "bufnum" item is always zero. The byte position of the cursor is returned in 'col'. To get the character position, use |getcursorcharpos()|. | |
Same as | |
The result is a String, which is the name of the current working directory. 'autochdir' is ignored. | |
Return the value of environment variable {name}. The {name} argument is a string, without a leading '$'. Example: | |
Without an argument returns the name of the normal font being
used. Like what is used for the Normal highlight group
| |
The result is a String, which is the read, write, and execute permissions of the given file {fname}. If {fname} does not exist or its directory cannot be read, an empty string is returned. The result is of the form "rwxrwxrwx", where each group of "rwx" flags represent, in turn, the permissions of the owner of the file, the group the file belongs to, and other users. If a user does not have a given permission the flag for this is replaced with the string "-". Examples: | |
The result is a Number, which is the size in bytes of the given file {fname}. If {fname} is a directory, 0 is returned. If the file {fname} can't be found, -1 is returned. If the size of {fname} is too big to fit in a Number then -2 is returned. | |
The result is a Number, which is the last modification time of
the given file {fname}. The value is measured as seconds
since 1st Jan 1970, and may be passed to strftime(). See also
| |
The result is a String, which is a description of the kind of file of the given file {fname}. If {fname} does not exist an empty string is returned. Here is a table over different kinds of files and their results: Normal file "file" Directory "dir" Symbolic link "link" Block device "bdev" Character device "cdev" Socket "socket" FIFO "fifo" All other "other" Example: | |
Returns the | |
Without {end} the result is a String, which is line {lnum} from the current buffer. Example: getline(1) When {lnum} is a String that doesn't start with a digit, |line()| is called to translate the String into a Number. To get the line under the cursor: getline(".") When {lnum} is a number smaller than 1 or bigger than the number of lines in the buffer, an empty string is returned. | |
Returns a | |
Without the {buf} argument returns a | |
Returns a | |
Returns a | |
Return a Number which is the process ID of the Vim process. On Unix and MS-Windows this is a unique number, until Vim exits. | |
Get the position for String {expr}. For possible values of {expr} see |line()|. For getting the cursor position see |getcurpos()|. The result is a |List| with four numbers: [bufnum, lnum, col, off] "bufnum" is zero, unless a mark like '0 or 'A is used, then it is the buffer number of the mark. "lnum" and "col" are the position in the buffer. The first column is 1. The "off" number is zero, unless 'virtualedit' is used. Then it is the offset in screen columns from the start of the character. E.g., a position within a or after the last character. Note that for '< and '> Visual mode matters: when it is "V" (visual line mode) the column of '< is zero and the column of '> is a large number equal to |v:maxcol|. The column number in the returned List is the byte position within the line. To get the character position in the line, use |getcharpos()|. A very large column number equal to |v:maxcol| can be returned, in which case it means "after the end of the line". If {expr} is invalid, returns a list with all zeros. This can be used to save and restore the position of a mark: let save_a_mark = getpos("'a") ... call setpos("'a", save_a_mark) Also see |getcharpos()|, |getcurpos()| and |setpos()|. | |
Returns a | |
The result is a String, which is the contents of register {regname}. Example: | |
Returns detailed information about register {regname} as a
Dictionary with the following entries:
regcontents List of lines contained in register
{regname}, like
|getreg|({regname}, 1, 1).
regtype the type of register {regname}, as in
|getregtype()|.
isunnamed Boolean flag, v:true if this register
is currently pointed to by the unnamed
register.
points_to for the unnamed register, gives the
single letter name of the register
currently pointed to (see |quotequote|).
For example, after deleting a line
with | |
The result is a String, which is type of register {regname}.
The value will be one of:
"v" for | |
If {tabnr} is not specified, then information about all the
tab pages is returned as a | |
Get the value of a tab-local variable {varname} in tab page
{tabnr}. | |
Get the value of window-local variable {varname} in window
{winnr} in tab page {tabnr}.
The {varname} argument is a string. When {varname} is empty a
dictionary with all window-local variables is returned.
When {varname} is equal to "&" get the values of all
window-local options in a | |
The result is a Dict, which is the tag stack of window {winnr}.
{winnr} can be the window number or the | |
Returns information about windows as a | |
The result is a | |
The result is a Number, which is the X coordinate in pixels of
the left hand side of the GUI Vim window. Also works for an
xterm (uses a timeout of 100 msec).
The result will be -1 if the information is not available.
The value can be used with | |
The result is a Number, which is the Y coordinate in pixels of
the top of the GUI Vim window. Also works for an xterm (uses
a timeout of 100 msec).
The result will be -1 if the information is not available.
The value can be used with | |
Like | |
f glob | Expand the file wildcards in {expr}. See |
Convert a file pattern, as used by glob(), into a search pattern. The result can be used to match with a string that is a file name. E.g. | |
Perform glob() for String {expr} on all directories in {path} and concatenate the results. Example: | |
f has | Returns 1 if {feature} is supported, 0 otherwise. The {feature} argument is a feature name like "nvim-0.2.1" or "win32", see below. See also |exists()|. |
The result is a Number, which is TRUE if | |
The result is a Number:
1 when the window has set a local directory via | |
The result is a Number, which is TRUE if there is a mapping
that contains {what} in somewhere in the rhs (what it is
mapped to) and this mapping exists in one of the modes
indicated by {mode}.
The arguments {what} and {mode} are strings.
When {abbr} is there and it is | |
Add the String {item} to the history {history} which can be one of: "cmd" or ":" command line history "search" or "/" search pattern history "expr" or "=" typed expression history "input" or "@" input line history "debug" or ">" debug command history empty the current or last used history The {history} string does not need to be the whole name, one character is sufficient. If {item} does already exist in the history, it will be shifted to become the newest entry. The result is a Number: TRUE if the operation was successful, otherwise FALSE is returned. | |
Clear {history}, i.e. delete all its entries. See | |
The result is a String, the entry with Number {index} from
{history}. See | |
The result is the Number of the current entry in {history}.
See | |
The result is a Number, which is TRUE if a highlight group called {name} exists. This is when the group has been defined in some way. Not necessarily when highlighting has been defined for it, it may also have been used for a syntax item. | |
f hlID | The result is a Number, which is the ID of the highlight group with name {name}. When the highlight group doesn't exist, zero is returned. This can be used to retrieve information about the highlight group. For example, to get the background color of the "Comment" group: |
The result is a String, which is the name of the machine on which Vim is currently running. Machine names greater than 256 characters long are truncated. | |
The result is a String, which is the text {string} converted
from encoding {from} to encoding {to}.
When the conversion completely fails an empty string is
returned. When some characters could not be converted they
are replaced with "?".
The encoding names are whatever the iconv() library function
can accept, see ":!man 3 iconv".
Most conversions require Vim to be compiled with the | |
The result is a Number, which is indent of line {lnum} in the
current buffer. The indent is counted in spaces, the value
of 'tabstop' is relevant. {lnum} is used just like in
| |
Find {expr} in {object} and return its index. See
| |
The result is a String, which is whatever the user typed on the command-line. The {prompt} argument is either a prompt string, or a blank string (for no prompt). A '\n' can be used in the prompt to start a new line. The highlighting set with |:echohl| is used for the prompt. The input is entered just like a command-line, with the same editing commands and mappings. There is a separate history for lines typed for input(). Example: :if input("Coffee or beer? ") == "beer" : echo "Cheers!" :endif | |
{textlist} must be a |List| of strings. This |List| is displayed, one string per line. The user will be prompted to enter a number, which is returned. The user can also select an item by clicking on it with the mouse, if the mouse is enabled in the command line ('mouse' is "a" or includes "c"). For the first string 0 is returned. When clicking above the first item a negative number is returned. When clicking on the prompt one more than the length of {textlist} is returned. Make sure {textlist} has less than 'lines' entries, otherwise it won't work. It's a good idea to put the entry number at the start of the string. And put a prompt in the first item. Example: let color = inputlist(['Select color:', '1. red', \ '2. green', '3. blue']) | |
Restore typeahead that was saved with a previous |inputsave()|. Should be called the same number of times inputsave() is called. Calling it more often is harmless though. Returns TRUE when there is nothing to restore, FALSE otherwise. | |
Preserve typeahead (also from mappings) and clear it, so that a following prompt gets input from the user. Should be followed by a matching inputrestore() after the prompt. Can be used several times, in which case there must be just as many inputrestore() calls. Returns TRUE when out of memory, FALSE otherwise. | |
This function acts much like the |input()| function with but two exceptions: a) the user's response will be displayed as a sequence of asterisks ("*") thereby keeping the entry secret, and b) the user's response will not be recorded on the input |history| stack. The result is a String, which is whatever the user actually typed on the command-line in response to the issued prompt. NOTE: Command-line completion is not supported. | |
When {object} is a | |
Interrupt script execution. It works more or less like the user typing CTRL-C, most commands won't execute and control returns to the user. This is useful to abort execution from lower down, e.g. in an autocommand. Example: | |
Bitwise invert. The argument is converted to a number. A List, Dict or Float argument causes an error. Example: | |
The result is a Number, which is | |
Return 1 if {expr} is a positive infinity, or -1 a negative infinity, otherwise 0. | |
The result is a Number, which is | |
Return | |
Return true if the value is Position. | |
Return true if the value is ScreenPos. | |
Check if the | |
Return a | |
f join | Join the items in {list} together into one String. When {sep} is specified it is put in between the items. If {sep} is omitted a single space is used. Note that {sep} is not added at the end. You might want to add it there too: |
This parses a JSON formatted string and returns the equivalent
in Vim values. See
| |
Encode {expr} as JSON and return this as a string.
The encoding is specified in:
https://tools.ietf.org/html/rfc7159.html
Vim values are converted as follows:
| |
f keys | Return a |
Turn the internal byte representation of keys into a form that
can be used for | |
f len | The result is a Number, which is the length of the argument.
When {expr} is a String or a Number the length in bytes is
used, as with |
Call function {funcname} in the run-time library {libname}
with single argument {argument}.
This is useful to call functions in a library that you
especially made to be used with Vim. Since only one argument
is possible, calling standard library functions is rather
limited.
The result is the String returned by the function. If the
function returns NULL, this will appear as an empty string ""
to Vim.
If the function returns a number, use libcallnr()!
If {argument} is a number, it is passed to the function as an
int; if {argument} is a string, it is passed as a
null-terminated string.
This function will fail in | |
Just like | |
f line | The result is a Number, which is the line number of the file position given with {expr}. The {expr} argument is a string. The accepted positions are: . the cursor position $ the last line in the current buffer 'x position of mark x (if the mark is not set, 0 is returned) w0 first line visible in current window (one if the display isn't updated, e.g. in silent Ex mode) w$ last line visible in current window (this is one less than "w0" if no lines are visible) v In Visual mode: the start of the Visual area (the cursor is the end). When not in Visual mode returns the cursor position. Differs from |'<| in that it's updated right away. Note that a mark in another file can be used. The line number then applies to another buffer. To get the column number use |col()|. To get both use |getpos()|. With the optional {winid} argument the values are obtained for that window instead of the current window. Returns 0 for invalid values of {expr} and {winid}. Examples: line(".") line number of the cursor line(".", winid) idem, in window "winid" line("'t") line number of mark t line("'" .. marker) line number of mark marker |
Return the byte count from the start of the buffer for line {lnum}. This includes the end-of-line character, depending on the 'fileformat' option for the current buffer. The first line returns 1. 'encoding' matters, 'fileencoding' is ignored. This can also be used to get the byte count for the line just below the last line: line2byte(line("$") + 1) This is the buffer size plus one. If 'fileencoding' is empty it is the file size plus one. {lnum} is used like with |getline()|. When {lnum} is invalid, or the |+byte_offset| feature has been disabled at compile time, -1 is returned. Also see |byte2line()|, |go| and |:goto|. | |
Get the amount of indent for line {lnum} according the lisp
indenting rules, as with 'lisp'.
The indent is counted in spaces, the value of 'tabstop' is
relevant. {lnum} is used just like in | |
Convert each number in {list} to a character string can concatenate them all. Examples: | |
Return the current time, measured as seconds since 1st Jan
1970. See also | |
f log | Return the natural logarithm (base e) of {expr} as a |
Return the logarithm of Float {expr} to base 10 as a | |
f map | {expr1} must be a |
When {dict} is omitted or zero: Return the rhs of mapping
{name} in mode {mode}. The returned String has special
characters translated like in the output of the ":map" command
listing. When {dict} is TRUE a dictionary is returned, see
below. To get a list of all mappings see | |
Check if there is a mapping that matches with {name} in mode
{mode}. See | |
Restore a mapping from a dictionary, possibly returned by
| |
When {expr} is a | |
Defines a pattern to be highlighted in the current window (a
"match"). It will be highlighted with {group}. Returns an
identification number (ID), which can be used to delete the
match using | |
Same as | |
Selects the {nr} match item, as set with a | |
Deletes a match with ID {id} previously defined by | |
Same as | |
If {list} is a list of strings, then returns a | |
Same as | |
Same as | |
Same as | |
Same as | |
f max | Return the maximum value of all items in {expr}. Example: |
Return information about the specified menu {name} in mode {mode}. The menu name should be specified without the shortcut character ('&'). If {name} is "", then the top-level menu names are returned. | |
f min | Return the minimum value of all items in {expr}. Example: |
Create directory {name}. | |
f mode | Return a string that indicates the current mode. If [expr] is supplied and it evaluates to a non-zero Number or a non-empty String (|non-zero-arg|), then the full mode is returned, otherwise only the first letter is returned. Also see |state()|. |
Return the line number of the first line at or below {lnum} that is not blank. Example: | |
Return a string with a single character, which has the number value {expr}. Examples: | |
f or | Bitwise OR on the two arguments. The arguments are converted
to a number. A List, Dict or Float argument causes an error.
Also see |
Shorten directory names in the path {path} and return the
result. The tail, the file name, is kept as-is. The other
components in the path are reduced to {len} letters in length.
If {len} is omitted or smaller than 1 then 1 is used (single
letters). Leading | |
Evaluate Perl expression {expr} in scalar context and return its result converted to Vim data structures. If value can't be converted, it is returned as a string Perl representation. Note: If you want an array or hash, {expr} must return a reference to it. Example: | |
f pow | Return the power of {x} to the exponent {y} as a |
Return the line number of the first line at or above {lnum} that is not blank. Example: | |
Return a String with {fmt}, where "%" items are replaced by the formatted form of their respective arguments. Example: | |
Returns the effective prompt text for buffer {buf}. {buf} can
be a buffer name or number. See | |
Set prompt callback for buffer {buf} to {expr}. When {expr} is an empty string the callback is removed. This has only effect if {buf} has 'buftype' set to "prompt". | |
Set a callback for buffer {buf} to {expr}. When {expr} is an empty string the callback is removed. This has only effect if {buf} has 'buftype' set to "prompt". | |
Set prompt for buffer {buf} to {text}. You most likely want {text} to end in a space. The result is only visible if {buf} has 'buftype' set to "prompt". Example: | |
If the popup menu (see | |
Returns non-zero when the popup menu is visible, zero
otherwise. See | |
Evaluate Python expression {expr} and return its result
converted to Vim data structures.
Numbers and strings are returned as they are (strings are
copied though, Unicode strings are additionally converted to
'encoding').
Lists are represented as Vim | |
Evaluate Python expression {expr} and return its result
converted to Vim data structures.
Numbers and strings are returned as they are (strings are
copied though).
Lists are represented as Vim | |
Evaluate Python expression {expr} and return its result
converted to Vim data structures.
Uses Python 2 or 3, see | |
f rand | Return a pseudo-random Number generated with an xoshiro128**
algorithm using seed {expr}. The returned number is 32 bits,
also on 64 bits systems, for consistency.
{expr} can be initialized by |
Returns a
| |
Return a list with file and directory names in {directory}.
You can also use | |
Read file {fname} and return a
| |
{func} is called for every item in {object}, which can be a
| |
Returns the single letter name of the register being executed.
Returns an empty string when no register is being executed.
See | |
Returns the single letter name of the register being recorded.
Returns an empty string when not recording. See | |
Return an item that represents a time value. The item is a
list with items that depend on the system. In Vim 9 script
list can be used.
The item can be passed to | |
Return a Float that represents the time value of {time}. Example: | |
Return a String that represents the time value of {time}. This is the number of seconds, a dot and the number of microseconds. Example: | |
Without {end}: Remove the item at {idx} from | |
Rename the file by the name {from} to the name {to}. This
should also work to move files across file systems. The
result is a Number, which is 0 if the file was renamed
successfully, and non-zero when the renaming failed.
NOTE: If {to} exists it is overwritten without warning.
This function is not available in the | |
Repeat {expr} {count} times and return the concatenated result. Example: | |
On MS-Windows, when {filename} is a shortcut (a .lnk file),
returns the path the shortcut points to in a simplified form.
When {filename} is a symbolic link or junction point, return
the full path to the target. If the target of junction is
removed, return {filename}.
On Unix, repeat resolving symbolic links in all path
components of {filename} and return the simplified result.
To cope with link cycles, resolving of symbolic links is
stopped after 100 iterations.
On other systems, return the simplified {filename}.
The simplification step is done as by | |
Reverse the order of items in {object} in-place.
{object} can be a | |
Round off {expr} to the nearest integral value and return it
as a | |
Evaluate Ruby expression {expr} and return its result
converted to Vim data structures.
Numbers, floats and strings are returned as they are (strings
are copied though).
Arrays are represented as Vim | |
Like | |
The result is a Number, which is the character at position [row, col] on the screen. This works for every possible screen position, also status lines, window separators and the command line. The top left position is row one, column one The character excludes composing characters. For double-byte encodings it may only be the first byte. This is mainly to be used for testing. Returns -1 when row or col is out of range. | |
The result is a | |
The result is a Number, which is the current screen column of the cursor. The leftmost column has number 1. This function is mainly used for testing. | |
The result is a Dict with the screen position of the text character in window {winid} at buffer line {lnum} and column {col}. {col} is a one-based byte index. The Dict has these members: row screen row col first screen column endcol last screen column curscol cursor screen column If the specified position is not visible, all values are zero. The "endcol" value differs from "col" when the character occupies more than one screen cell. E.g. for a Tab "col" can be 1 and "endcol" can be 8. The "curscol" value is where the cursor would be placed. For a Tab it would be the same as "endcol", while for a double width character it would be the same as "col". The |conceal| feature is ignored here, the column numbers are as if 'conceallevel' is zero. You can set the cursor to the right position and use |screencol()| to get the value with |conceal| taken into account. If the position is in a closed fold the screen position of the first character is returned, {col} is not used. Returns an empty Dict if {winid} is invalid. | |
The result is a Number, which is the current screen row of the
cursor. The top line has number one.
This function is mainly used for testing.
Alternatively you can use | |
The result is a String that contains the base character and
any composing characters at position [row, col] on the screen.
This is like | |
Search for regexp pattern {pattern}. The search starts at the
cursor position (you can use | |
Get or update the last search count, like what is displayed without the "S" flag in 'shortmess'. This works even if 'shortmess' does contain the "S" flag. | |
Search for the declaration of {name}. | |
Search for the match of a nested start-end pair. This can be used to find the "endif" that matches an "if", while other if/endif pairs in between are ignored. The search starts at the cursor. The default is to search forward, include 'b' in {flags} to search backward. If a match is found, the cursor is positioned at it and the line number is returned. If no match is found 0 or -1 is returned and the cursor doesn't move. No error message is given. | |
Same as | |
Same as | |
Return a list of available server names, one per line.
When there are no servers or the information is not available
an empty string is returned. See also | |
Set line {lnum} to {text} in buffer {buf}. This works like |setline()| for the specified buffer. | |
Set option or local variable {varname} in buffer {buf} to
{val}.
This also works for a global or local window option, but it
doesn't work for a global or local window variable.
For a local window option the global value is unchanged.
For the use of {buf}, see | |
Specify overrides for cell widths of character ranges. This tells Vim how wide characters are, counted in screen cells. This overrides 'ambiwidth'. Example: | |
Same as | |
Set the current character search information to {dict}, which contains one or more of the following entries: | |
Set the command line to {str} and set the cursor position to {pos}. If {pos} is omitted, the cursor is positioned after the text. Returns 0 when successful, 1 when not editing the command line. | |
Set the cursor position in the command line to byte position
{pos}. The first position is 1.
Use | |
Same as | |
Set environment variable {name} to {val}. Example: | |
Set the file permissions for {fname} to {mode}. {mode} must be a string with 9 characters. It is of the form "rwxrwxrwx", where each group of "rwx" flags represent, in turn, the permissions of the owner of the file, the group the file belongs to, and other users. A '-' character means the permission is off, any other character means on. Multi-byte characters are not supported. | |
Set line {lnum} of the current buffer to {text}. To insert lines use |append()|. To set lines in another buffer use |setbufline()|. Any text properties in {lnum} are cleared. | |
Create or replace or add to the location list for window {nr}.
{nr} can be the window number or the | |
Restores a list of matches saved by | |
Set the position for String {expr}. Possible values: . the cursor 'x mark x {list} must be a |List| with four or five numbers: [bufnum, lnum, col, off] [bufnum, lnum, col, off, curswant] | |
Create or replace or add to the quickfix list. | |
Set the register {regname} to {value}.
If {regname} is "" or "@", the unnamed register '"' is used.
The {regname} argument is a string. In | |
Set tab-local variable {varname} to {val} in tab page {tabnr}.
| |
Set option or local variable {varname} in window {winnr} to
{val}.
Tabs are numbered starting with one. For the current tabpage
use | |
Modify the tag stack of the window {nr} using {dict}.
{nr} can be the window number or the | |
Like | |
Returns a String with 64 hex characters, which is the SHA256 checksum of {string}. | |
Escape {string} for use as a shell command argument. When the 'shell' contains powershell (MS-Windows) or pwsh (MS-Windows, Linux, and macOS) then it will enclose {string} in single quotes and will double up all internal single quotes. On MS-Windows, when 'shellslash' is not set, it will enclose {string} in double quotes and double all double quotes within {string}. Otherwise it will enclose {string} in single quotes and replace all "'" with "'''". | |
Returns the effective value of 'shiftwidth'. This is the 'shiftwidth' value unless it is zero, in which case it is the 'tabstop' value. This function was introduced with patch 7.3.694 in 2012, everybody should have it by now (however it did not allow for the optional {col} argument until 8.1.542). | |
Simplify the file name as much as possible without changing the meaning. Shortcuts (on MS-Windows) or symbolic links (on Unix) are not resolved. If the first path component in {filename} designates the current directory, this will be valid for the result as well. A trailing path separator is not removed either. On Unix "//path" is unchanged, but "///path" is simplified to "/path" (this follows the Posix standard). Example: | |
f sin | Return the sine of {expr}, measured in radians, as a |
f sinh | Return the hyperbolic sine of {expr} as a |
f sort | Sort the items in {list} in-place. Returns {list}. |
Return the sound-folded equivalent of {word}. Uses the first language in 'spelllang' for the current window that supports soundfolding. 'spell' must be set. When no sound folding is possible the {word} is returned unmodified. This can be used for making spelling suggestions. Note that the method can be quite slow. | |
Without argument: The result is the badly spelled word under or after the cursor. The cursor is moved to the start of the bad word. When no bad word is found in the cursor line the result is an empty string and the cursor doesn't move. | |
Return a | |
Make a | |
f sqrt | Return the non-negative square root of Float {expr} as a
|
Initialize seed used by
| |
Convert String {string} to a Float. This mostly works the
same as when using a floating point number in an expression,
see | |
Return a list containing the number values which represent each character in String {string}. Examples: | |
Convert string {string} to a number. {base} is the conversion base, it can be 2, 8, 10 or 16. When {quoted} is present and non-zero then embedded single quotes are ignored, thus "1'000'000" is a million. | |
Like | |
The result is a Number, which is the number of characters
in String {string}.
When {skipcc} is omitted or zero, composing characters are
counted separately.
When {skipcc} set to 1, Composing characters are ignored.
| |
The result is a Number, which is the number of display cells
String {string} occupies on the screen when it starts at {col}
(first column is zero). When {col} is omitted zero is used.
Otherwise it is the screen column where to start. This
matters for Tab characters.
The option settings of the current window are used. This
matters for anything that's displayed differently, such as
'tabstop' and 'display'.
When {string} contains characters with East Asian Width Class
Ambiguous, this function's return value depends on 'ambiwidth'.
Returns zero on error.
Also see | |
The result is a String, which is a formatted date and time, as
specified by the {format} string. The given {time} is used,
or the current time if no time is given. The accepted
{format} depends on your system, thus this is not portable!
See the manual page of the C function strftime() for the
format. The maximum length of the result is 80 characters.
See also | |
Get a Number corresponding to the character at {index} in
{str}. This uses a zero-based character index, not a byte
index. Composing characters are considered separate
characters here. Use | |
The result is a Number, which gives the byte index in {haystack} of the first occurrence of the String {needle}. If {start} is specified, the search starts at index {start}. This can be used to find a second match: | |
Return {expr} converted to a String. If {expr} is a Number,
Float, String, Blob or a composition of them, then the result
can be parsed back with | |
The result is a Number, which is the length of the String
{string} in bytes.
If the argument is a Number it is first converted to a String.
For other types an error is given and zero is returned.
If you want to count the number of multibyte characters use
| |
The result is a String, which is part of {src}, starting from
byte {start}, with the byte length {len}.
When {chars} is present and TRUE then {len} is the number of
characters positions (composing characters are not counted
separately, thus "1" means one base character and any
following composing characters).
To count {start} as characters instead of bytes use
| |
The result is a Number, which is a unix timestamp representing the date and time in {timestring}, which is expected to match the format specified in {format}. | |
The result is a Number, which gives the byte index in {haystack} of the last occurrence of the String {needle}. When {start} is specified, matches beyond this index are ignored. This can be used to find a match before a previous match: | |
The result is a String, which is {string} with all unprintable
characters translated into printable characters | |
The result is a Number, which is the number of display cells
String {string} occupies. A Tab character is counted as one
cell, alternatively use | |
Only for an expression in a | |
The result is a String, which is a copy of {string}, in which the first match of {pat} is replaced with {sub}. When {flags} is "g", all matches of {pat} in {string} are replaced. Otherwise {flags} should be "". | |
The result is a dictionary, which holds information about the swapfile {fname}. The available fields are: version Vim version user user name host host name fname original file name pid PID of the Vim process that created the swap file mtime last modification time in seconds inode Optional: INODE number of the file dirty 1 if file was modified, 0 if not Note that "user" and "host" are truncated to at most 39 bytes. In case of failure an "error" item is added with the reason: Cannot open file: file not found or in accessible Cannot read file: cannot read first block Not a swap file: does not contain correct block ID Magic number mismatch: Info in first block is invalid | |
The result is the swap file path of the buffer {expr}.
For the use of {buf}, see | |
The result is a
| |
The result is a Number, which is the syntax ID at the position
{lnum} and {col} in the current window.
The syntax ID can be used with | |
The result is a String, which is the {what} attribute of
syntax ID {synID}. This can be used to obtain information
about a syntax item.
{mode} can be "gui", "cterm" or "term", to get the attributes
for that mode. When {mode} is omitted, or an invalid value is
used, the attributes for the currently active highlighting are
used (GUI, cterm or term).
Use synIDtrans() to follow linked highlight groups.
{what} result
"name" the name of the syntax item
"fg" foreground color (GUI: color name used to set
the color, cterm: color number as a string,
term: empty string)
"bg" background color (as with "fg")
"font" font name (only available in the GUI)
| |
The result is a Number, which is the translated syntax ID of {synID}. This is the syntax group ID of what is being used to highlight the character. Highlight links given with ":highlight link" are followed. | |
Return a | |
Get the output of the shell command {expr} as a | |
Same as | |
The result is a | |
The result is a Number, which is the number of the current tab page. The first tab page has number 1. | |
Like
| |
Returns a | |
Returns a | |
f tan | Return the tangent of {expr}, measured in radians, as a |
f tanh | Return the hyperbolic tangent of {expr} as a |
The result is a String, which is the name of a file that doesn't exist. It can be used for a temporary file. The name is different for at least 26 consecutive calls. Example: | |
Return a list with information about timers. When {id} is given only information about this timer is returned. When timer {id} does not exist an empty list is returned. When {id} is omitted information about all timers is returned. | |
Pause or unpause a timer. A paused timer does not invoke its callback when its time expires. Unpausing a timer may cause the callback to be invoked almost immediately if enough time has passed. | |
Create a timer and return the timer ID. | |
Stop a timer. The timer callback will no longer be invoked. {timer} is an ID returned by timer_start(), thus it must be a Number. If {timer} does not exist there is no error. | |
Stop all timers. The timer callbacks will no longer be invoked. Useful if a timer is misbehaving. If there are no timers there is no error. | |
The result is a copy of the String given, with all uppercase
characters turned into lowercase (just like applying | |
The result is a copy of the String given, with all lowercase
characters turned into uppercase (just like applying | |
f tr | The result is a copy of the {src} string with all characters which appear in {fromstr} replaced by the character in that position in the {tostr} string. Thus the first character in {fromstr} is translated into the first character in {tostr} and so on. Exactly like the unix "tr" command. This code also deals with multibyte characters properly. |
f trim | Return {text} as a String where any character in {mask} is removed from the beginning and/or end of {text}. |
Return the largest integral value with magnitude less than or
equal to {expr} as a | |
f type | The result is a Number representing the type of {expr}.
Instead of using the number directly, it is better to use the
v:t_ variable that has the value:
Number: 0 |
Return the name of the undo file that would be used for a file
with name {name} when writing. This uses the 'undodir'
option, finding directories that exist. It does not check if
the undo file exists.
{name} is always expanded to the full path, since that is what
is used internally.
If {name} is empty undofile() returns an empty string, since a
buffer without a file name will not write an undo file.
Useful in combination with | |
Return the current state of the undo tree in a dictionary with
the following items:
"seq_last" The highest undo sequence number used.
"seq_cur" The sequence number of the current position in
the undo tree. This differs from "seq_last"
when some changes were undone.
"time_cur" Time last used for | |
f uniq | Remove second and succeeding copies of repeated adjacent {list} items in-place. Returns {list}. If you want a list to remain unmodified make a copy first: |
Return a | |
The result is a Number, which is the screen column of the file position given with {expr}. That is, the last screen position occupied by the character at that position, when the screen would be of unlimited width. When there is a at the position, the returned Number will be the column at the end of the . For example, for a in column 1, with 'ts' set to 8, it returns 8. |conceal| is ignored. For the byte position use |col()|. For the use of {expr} see |col()|. When 'virtualedit' is used {expr} can be [lnum, col, off], where "off" is the offset in screen columns from the start of the character. E.g., a position within a or after the last character. When "off" is omitted zero is used. When Virtual editing is active in the current mode, a position beyond the end of the line can be returned. Also see |'virtualedit'| The accepted positions are: . the cursor position $ the end of the cursor line (the result is the number of displayed characters in the cursor line plus one) 'x position of mark x (if the mark is not set, 0 is returned) v In Visual mode: the start of the Visual area (the cursor is the end). When not in Visual mode returns the cursor position. Differs from |'<| in that it's updated right away. Note that only marks in the current file can be used. Examples: virtcol(".") with text "foo^Lbar", with cursor on the "L", returns 5 virtcol("$") with text "fooLbar", returns 9 virtcol("'t") with text " there", with 't at 'h', returns 6 The first column is 1. 0 is returned for an error. A more advanced example that echoes the maximum length of all lines: echo max(map(range(1, line('$')), "virtcol([v:val, '$'])")) Can also be used as a |method|: GetPos()->virtcol() | |
The result is a Number, which is the byte index of the character in window {winid} at buffer line {lnum} and virtual column {col}. | |
The result is a String, which describes the last Visual mode
used in the current buffer. Initially it returns an empty
string, but once Visual mode has been used, it returns "v",
"V", or | |
Returns | |
Like | |
Returns a | |
Get the | |
Return the type of the window:
"autocmd" autocommand window. Temporary window
used to execute autocommands.
"command" command-line window | |
Go to window with ID {expr}. This may also change the current tabpage. Return TRUE if successful, FALSE if the window cannot be found. | |
Return a list with the tab number and window number of window with ID {expr}: [tabnr, winnr]. Return [0, 0] if the window cannot be found. | |
Return the window number of window with ID {expr}. Return 0 if the window cannot be found in the current tabpage. | |
Move window {nr}'s vertical separator (i.e., the right border)
by {offset} columns, as if being dragged by the mouse. {nr}
can be a window number or | |
Move window {nr}'s status line (i.e., the bottom border) by
{offset} rows, as if being dragged by the mouse. {nr} can be a
window number or | |
Return the screen position of window {nr} as a list with two
numbers: [row, col]. The first window always has position
[1, 1], unless there is a tabline, then it is [2, 1].
{nr} can be the window number or the | |
Move the window {nr} to a new split of the window {target}.
This is similar to moving to {target}, creating a new window
using | |
The result is a Number, which is the number of the buffer
associated with window {nr}. {nr} can be the window number or
the | |
The result is a Number, which is the virtual column of the cursor in the window. This is counting screen cells from the left side of the window. The leftmost column is one. | |
The result is a String. For MS-Windows it indicates the OS version. E.g, Windows 10 is "10.0", Windows 8 is "6.2", Windows XP is "5.1". For non-MS-Windows systems the result is an empty string. | |
The result is a Number, which is the height of window {nr}.
{nr} can be the window number or the | |
The result is a nested List containing the layout of windows in a tabpage. | |
The result is a Number, which is the screen line of the cursor in the window. This is counting screen lines from the top of the window. The first line is one. If the cursor was moved the view on the file will be updated first, this may cause a scroll. | |
The result is a Number, which is the number of the current window. The top window has number 1. Returns zero for a popup window. | |
Returns a sequence of | |
Uses the | |
Returns a | |
The result is a Number, which is the width of window {nr}.
{nr} can be the window number or the | |
The result is a dictionary of byte/chars/word statistics for
the current buffer. This is the same info as provided by
| |
When {object} is a | |
f xor | Bitwise XOR on the two arguments. The arguments are converted
to a number. A List, Dict or Float argument causes an error.
Also see |
Type Aliases
Builtin completion | |
Type of | |
Type of |