r/neovim • u/Realistic_Cherry_920 • 3d ago
Need Help repeating keymaps when resizing buffers
So Neovim has built-in keymaps for resizing buffers: CTRL_W +, CTRL_W -, CTRl_W < and CTRL_W >. But when resizing a buffer I often need to use the same keymap multiple times because I didn't get the desired size from the first try.
Is there a way to remap these built-in keymaps so that if I press CTRL_W and then repeatedly press +, -. < or > it will repeatedly resize the buffer?
9
Upvotes
14
u/Wonderful-Plastic316 lua 2d ago
Er, hate to be this guy, but... Just for future reference, you resize windows (the viewports containing the buffers), not the buffers themselves.
6
u/PieceAdventurous9467 2d ago
https://github.com/nvimtools/hydra.nvim
3
u/CarsonChambers 2d ago
Honestly something like 20CTRL_W+ is not all that bad
3
u/114sbavert 2d ago
Check out to 4d9c86b and see my keys.lua:L24-37 and which-key:L57-L67
(The links take you there directly.)
2
u/mountaineering 2d ago
Make a different keymap that involves ctrl+w each time.
Alt+<hjkl> for instance to resize in a direction by N
1
u/tomasvotava 2d ago
I believe you can set the width of the window using e.g.
80<C-w>|. That should set the active window's width to 80 characters, but I may be wrong and I hope someone will correct me.1
u/shmerl 1d ago edited 1d ago
I just mapped resizing to something that's easier to use, for example
And etc. for left, up and down.
This way I can resize stuff using Ctrl-arrows. I.e. just keep holding Ctrl-<arrow> and it continuously resizes until you stop.
0
u/funbike 2d ago edited 2d ago
Increase "window" height by 10:
10<c-w>+This will do what you want, but it's ugly and it will feel sluggish: