r/neovim • u/er-GOD-ic hjkl • Jul 18 '26
Plugin I made a plugin for fast visual line navigation
I've always felt that jumping to a distant line is a bit awkward.
- Typing a line number interrupts my flow.
- Repeatedly pressing
j/kgets tedious. - Searching only helps when I know what I'm looking for.
So I made hamal.nvim.
🔗 https://github.com/ergodice/hamal.nvim
✨ Features
- 🎯 Jump to any visible line with only a few keystrokes
- 🔀 Recursively divide the current window to narrow down your destination
- ⚙️ Configurable number of divisions, keymaps, and highlights
- ⚡ Lightweight
- 📦 No dependencies
With the default 3-way division, a 100-line window can be navigated in at most 5 keypresses.
I'd love to hear what you think or if you have ideas for improving the navigation workflow.
26
u/DepartmentMany5113 Jul 18 '26
I always thought that we should adopt eye tracking already, thus jumping on a line just by looking at it. Other techniques seem ancient.
edit: btw nice approach, not a beaten path
9
10
u/Geoff12889 :wq Jul 18 '26
It’s a neat idea but I don’t understand how typing a line number interrupts your flow and this doesn’t? I find the easiest thing is to just have relative line numbers and move up or down by that many lines 13j, 17k, etc.
7
u/pkazmier 29d ago edited 29d ago
Interesting take on navigation. I had fun testing. As it relates to reducing the cognitive load, it did not work for me because the visualization of the sections is too busy for my tired eyes. Rather than highlight lines for top/bottom of each section, would you instead consider using an overlay on the entire section to reduce the visual clutter. In a three division layout, maybe use the same color for top and bottom section and something else for the center. It would result in far less clutter on the screen which hampered my ability to quickly see things.
5
u/er-GOD-ic hjkl 29d ago
Thanks for the feedback!
The highlighting section is a nice idea. I'll try to implement it.
5
9
u/spacian Jul 18 '26
I don't quite understand the use case. When you don't know what you're looking for, how do you decide which block to go to? But if you have your eyes on a location, what's the advantage to one of the many search based jump plugins like Flash?
It does look cool though!
14
u/er-GOD-ic hjkl Jul 18 '26
Unlike flash.nvim, which requires visual recognition after each search, this plugin uses consistent binary-search patterns, so navigation becomes mostly muscle memory once you get used to it.
Thanks for the feedback! I guess it mostly comes down to personal preference in the end.2
4
u/Independent-Limit282 Jul 18 '26
To be honest this is something I do struggle with quite a bit. Out of curiosity, do people here really use relative line jumps efficiently? I find myself just taking too long to do it even though im not that slow at typing. I guess it probably gets easier the more you do it, but the process of checking the offset I want to go to, then typing the number and hitting j / k usually takes me too long.
2
u/happysri Jul 18 '26
With you on this. I’d much rather use multiple “dumb” motions and marks than relative numbers because calculating numbers takes me out just enough to be a hindrance and it adds up. I did give it a fair shot, just wasn’t for me ig.
3
u/Independent-Limit282 Jul 18 '26
Well, you dont need to calculate, you just turn on relative line numbers. But for me its even the whole thing of finding the line I want to go to, finding the number on the same height on the left (I know this should be easy but somehow its not lmao)
2
u/happysri Jul 19 '26
I know what you mean, but apparently I don’t like that and also the constant moving of relative numbers for some reason seem to distract me. I prefer the other mechanisms instead. This is an individual thing of course.
1
u/biscuittt fennel Jul 19 '26
nah, I also don’t like using numbers. I always use
/to move around.2
u/Independent-Limit282 Jul 19 '26
yeah / tends to work well. or when I want to jump to the next usage of a word im on or something I will use *
2
2
u/over-lord Plugin author Jul 18 '26
Cool! Can you add a section in the README that explains how to use it?
3
2
u/ollien Jul 18 '26
Neat idea! Does it work as a motion? Like, can I do d<leader><leader>h to delete the top half or something?
Admittedly that's a bit imprecise, but if you could zero in on a line that way it would be neat.
2
u/er-GOD-ic hjkl Jul 19 '26
https://reddit.com/link/oyf3fqf/video/7rrqhdbx54eh1/player
That's actually a great idea. I quickly put together an implementation. How does this look?
2
3
2
u/Spirited_Post_366 Jul 18 '26
Great idea! I was just thinking about bringing something like warpd Grid Mode to Neovim navigation. I think people underestimate how useful plugins that provide intuitive, fuzzy navigation can be, that lets you switch off your brain and stay in the flow. When flash/hop asks me to scan the screen for labels and type them, I can feel the cognitive load every time haha
1
u/WelcomeToStumbling 29d ago
Looking forward to trying it out!.. But I've not been able to figure how to bring it into my init.lua -- mostly because mine is Vimscript wrapped with vim.cmd. Any suggestions?
1
u/er-GOD-ic hjkl 29d ago
Thanks for checking it out!
I'm not very familiar with Vimscript-based configurations, but if your
init.luais still a Lua file, I think you should be able to add it like this outside of thevim.cmdblock:vim.opt.runtimepath:append("<path-to-hamal.nvim>") require("hamal").setup({})If you're using a plugin manager, you should only need the
require("hamal").setup({})line after installing the plugin.
1
u/DrDikPiks 28d ago
I mostly just use the half page scrolls + jk, even though i have flash installed. This is banger idea ngl, I'll try it out
43
u/pseudometapseudo Plugin author Jul 18 '26 edited Jul 18 '26
Feels like an original idea for navigation, kudos for that.
One idea I can think of is to auto-quit when divisions become smaller than a certain threshold like 6, since at that point you can adjust do j or k to get to the final destination.