Iron-E / nvim-cartographer

Create Neovim `:map`pings in Lua with ease!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to set a count before a noremap?

alxndr opened this issue · comments

e.g. in Vimscript:

nnoremap <expr> <C-d> (winheight(0) / 3) . '<C-d>'
nnoremap <expr> <C-u> (winheight(0) / 3) . '<C-u>'

from https://neovim.discourse.group/t/how-to-make-ctrl-d-and-ctrl-u-scroll-1-3-of-window-height/859/2

I'm not sure what you mean by setting a count to noremap, because I've never seen 3noremap or something like that.

But if you want to translate those mappings you can use:

local nnoremap = require('cartographer').n.nore.expr

nnoremap['<C-u>'] = "(winheight(0) / 3) . '<C-u>'"

Aha, I was missing that I needed to use expr, thank you!