Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ddc_vim/deps.ts>fn.getcurpos

Dark deno-powered completion framework for neovim/Vim
Go to Latest
function fn.getcurpos
import { fn } from "https://deno.land/x/ddc_vim@v4.0.5/deps.ts";
const { getcurpos } = fn;

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().

The optional {winid} argument can specify the window. It can be the window number or the window-ID. The last known cursor position is returned, this may be invalid for the current value of the buffer if it is not the current window. If {winid} is invalid a list with zeroes is returned.

This can be used to save and restore the cursor position:

let save_cursor = getcurpos()
MoveTheCursorAround
call setpos('.', save_cursor)

Note that this only works within the window. See winrestview() for restoring more state.

Can also be used as a method:

GetWinid()->getcurpos()

Parameters

denops: Denops
optional
winid: number | string