Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

btv.pos

btv.pos.get(expr)

btv.pos.get(expr) [alias vim.fn.getpos]: a position as { bufnr, lnum, col, off } (1-based lnum/col, off always 0). expr is one of:

"."     the cursor
"v"     the fixed end of the live Visual selection (the cursor is the other
        end); outside Visual mode, the cursor
"$"     the last line, with col 0
"'<"    start of the last Visual selection (after leaving Visual mode)
"'>"    end of the last Visual selection
"'x"    mark x: a-z, A-Z, 0-9, or one of " ' ` . ^ [ ]

A buffer-local mark reports bufnr 0; a file mark (A–Z, 0–9) reports the buffer it points into. A mark that is not set yields { 0, 0, 0, 0 }, as in vim. Any other expression ("w0", "w$", an invalid mark name) raises an error naming it. Reads the server-pushed cursor, selection-anchor and marks mirrors. To read a visual selection from a Visual-mode mapping, pair "v" with "."; "'<" / "'>" only update once the selection is left.

Defined in vimfn.lua.

btv.pos.set(expr, pos)

btv.pos.set(expr, pos) [alias vim.fn.setpos]: move the cursor or set a mark. pos is { bufnr, lnum, col, off } (1-based lnum/col; off is ignored), and the call returns 0. expr is one of:

"."     the cursor (in the current window; `bufnr` is ignored)
"'x"    mark x: a-z, A-Z, or one of ' ` " [ ] < >

A mark goes into buffer bufnr, 0 meaning the current one; an uppercase mark remembers that buffer as its file. The column is clamped to the line. The mark is written in order with btv.cmd, so btv.cmd("normal! gv") after setting "'<" and "'>" selects the new range. Any other expression ("'.", a numbered mark, "w0") raises an error naming it, and so does a line outside the buffer.

Defined in vimfn.lua.