I want to jump to line 55. I can do this with a normal motion in Vim. I can do this programmatically from Lua using vim.cmd
. But is there a dedicated Lua function for this?
55
G
local line = 55
vim.cmd('normal ' .. line .. 'G')
local line = 55
-- <your answer here>
Lua way of doing this is using vim.api.nvim_win_set_cursor
call.
local line = 55
vim.api.nvim_win_set_cursor(0, {line, 0})
(or)
You can use :55
in command
mode to switch to 55th line.
So in lua..
local line = 55
vim.cmd(":"..line)