0

I want to get the line number by a mark, is it possible to do it in nvim in Lua? I have searched the doc for mark but I cannot find anything useful.

https://neovim.io/doc/user/lua.html

1
  • 1
    why not using vimscript functions line() and getpos() May 18 at 8:21
1

You can use :h nvim_buf_get_mark() line this:

local r, c = unpack(vim.api.nvim_buf_get_mark(0, "a"))
print(string.format("row: [%d], col: [%d]", r, c))

The first argument is the reference to the buffer (0 is the current buffer) and the second argument is the name of the mark.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.