As title. Since no one wants to become a turtle, I want to setup a behavior like M
but instead pin the current line to 80% height (0% start from bottom) of the current window, not to center.
1 Answer
Update
Since I don't like scrolloff, I update to this new version:
vim.api.nvim_set_keymap('n', 'M', '<cmd>lua pin_to_80_percent_height()<CR>', NOREF_NOERR_TRUNC)
function _G.pin_to_80_percent_height()
vim.opt.scrolloff = 5
vim.cmd("exe 'normal! zt'")
vim.opt.scrolloff = 0
end
old answer
Set
scrolloff
to5
vim.opt.scrolloff = 5
Set keymap
M
tozt
.vim.api.nvim_set_keymap('n', 'M', 'zt', NOREF_NOERR_TRUNC)