improve ctrl-u/d scroll size

This commit is contained in:
2026-06-05 18:46:00 +03:00
parent 7248185c04
commit c98608240b
3 changed files with 15 additions and 14 deletions

View File

@@ -23,13 +23,20 @@ vim.keymap.set('x', 'K', ":m '<-2<CR>gv=gv")
vim.keymap.set('n', '<leader>s', [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/g<Left><Left><Left>]])
-- Scroll
-- vim.keymap.set('n', '<C-d>', function()
-- vim.cmd('normal! ' .. math.floor(vim.api.nvim_win_get_height(0) * 0.25) .. 'j')
-- end)
--
-- vim.keymap.set('n', '<C-u>', function()
-- vim.cmd('normal! ' .. math.floor(vim.api.nvim_win_get_height(0) * 0.25) .. 'k')
-- end)
local function scroll(cmd)
local count = vim.v.count
local height = vim.api.nvim_win_get_height(0)
vim.opt_local.scroll = math.max(1, math.min(count > 0 and count or 20, height))
vim.cmd.normal({ vim.api.nvim_replace_termcodes(cmd, true, false, true), bang = true })
end
map('n', '<C-d>', function()
scroll('<C-d>')
end)
map('n', '<C-u>', function()
scroll('<C-u>')
end)
-- Easy to use registers
map('x', '<leader>p', '"_dP')