import { fn } from "https://deno.land/x/ddc_vim@v4.1.0/deps.ts";
const { setpos } = fn;
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]
"bufnum" is the buffer number. Zero can be used for the
current buffer. When setting an uppercase mark "bufnum" is
used for the mark position. For other marks it specifies the
buffer to set the mark in. You can use the bufnr()
function
to turn a file name into a buffer number.
For setting the cursor and the ' mark "bufnum" is ignored,
since these are associated with a window, not a buffer.
Does not change the jumplist.
"lnum" and "col" are the position in the buffer. The first
column is 1. Use a zero "lnum" to delete a mark. If "col" is
smaller than 1 then 1 is used. To use the character count
instead of the byte count, use setcharpos()
.
The "off" number is only used when 'virtualedit' is set. Then
it is the offset in screen columns from the start of the
character. E.g., a position within a <Tab>
or after the last
character.
The "curswant" number is only used when setting the cursor position. It sets the preferred column for when moving the cursor vertically. When the "curswant" number is missing the preferred column is not set. When it is present and setting a mark position it is not used.
Note that for '< and '> changing the line number may result in the marks to be effectively be swapped, so that '< is always before '>.
Returns 0 when the position could be set, -1 otherwise. An error message is given if {expr} is invalid.
Also see setcharpos()
, getpos()
and getcurpos()
.
This does not restore the preferred column for moving
vertically; if you set the cursor position with this, j
and
k
motions will jump to previous columns! Use cursor()
to
also set the preferred column. Also see the "curswant" key in
winrestview()
.
Can also be used as a method
:
GetPosition()->setpos('.')