[mini.jump2d] Optimized jumping with jump2d #1033
Replies: 3 comments 26 replies
-
Thank you for this PhD-level (in a good way :) ) comment. I somewhat agree with you about mental pauses. If I remember correctly, the main reason to choose default as it is now was to ensure that any jump can be made only with configured labels. Typing first character can lead to certain inconveniences in some situations:
I think I'll try the "jump to single character" as default for a while. I doubt the default spotter in 'mini.jump2d' itself would change, but maybe my default will change :) |
Beta Was this translation helpful? Give feedback.
-
I would like to say that the quality of your posts is inspirational. Following your example, I also put a lot of extra thought in the way I jump. I found a jump2d configuration that now replaces @echasnovski: That's number 22...;) local Jump2d = require("mini.jump2d")
local function map(mode, rhs, opts) -- adapted from mini.jump2d
local lhs = "<CR>" -- "s"
opts = vim.tbl_deep_extend("force", { silent = true }, opts or {})
vim.keymap.set(mode, lhs, rhs, opts)
end
local function start_in_normal_mode()
local builtin = Jump2d.builtin_opts.word_start
builtin.view = { n_steps_ahead = 10 }
Jump2d.start(builtin)
end
local function start()
local builtin = Jump2d.builtin_opts.single_character
Jump2d.start(builtin)
end
Jump2d.setup({ mappings = { start_jumping = "" } }) -- no mappings
map("n", start_in_normal_mode, { desc = "Start 2d jumping" })
map({ "x", "o" }, start, { desc = "Start 2d jumping" }) Intent in normal mode using word_start
Note:
Intent in visual and operator pending mode using single_characterAll characters must be reachable. Speed is less important. No need for n_steps_ahead Other spotters
RemoteLeap remote is quite spectacular. However, an extra Demojumping_all.mp4 |
Beta Was this translation helpful? Give feedback.
-
With all these discussions around 'mini.jump2d', I've remembered a silly anecdote. One of the first things I did after there was a working prototype for narrowing down shown labels was playing around for good several minutes just navigating with binary labels. Something like this: mini-jump2d_binary-labels.mp4For some reason I found this amusing. Well, still do 🤣 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've been experimenting with various configurations in
jump2d
to improve the perceived latency from initiating a jump to reaching the target destination. The default configuration ofjump2d
has always left me underwhelmed in this regard. Further, visually, it's rather busy and if you lose sight of your target in step one, it can be hard to find it again as labels obscure so much of the page.Optimized
Fortunately,
jump2d
provides several options to tune that experience, so I'm sharing a configuration that feels faster in all regards to me.Rationale
In the default configuration, there are two mental pauses required to reach locations—and not all locations are reachable requiring further movement post jump. By mental pause, I mean you need to wait for a label to appear, visually parse it, and then press the character. With the defaults, you need to do this twice, which feels slow compared to other similar plug-ins. For example, a typical jump sequence using the defaults:
With the optimized configuration above, there is only a single mental pause required thanks to the
single_character
built-in. A typical jump sequence works like this using the optimized configuration:n_steps_ahead
). In the case of one label, the number of keys pressed is the same as the default scenario, but with one less mental pauses, so it feels much faster. In the case of two labels, while there may be an additional key press over the default, it still feels faster as there is only one mental pause required because both labels are shown immediately. But, I reduce the chance of the two label scenario by including capital letters in the label set, which is still faster for me than two separate labels.Demos
Here are several demos showing the default (red bg) and the optimized (green bg) configurations. Below are the lines of code displayed in the videos. For each of demo below, I'll start with the cursor on line 1 and reference the line number that the target is on.
Fast path
Admittedly, it's not often that there is only a single instance of the target character, but it does happen sometimes.
Target:
5
on line 30.Screen.Recording.2024-07-08.at.10.28.32.AM.mov
Screen.Recording.2024-07-08.at.10.27.52.AM.mov
Single label
Target:
r
in "[r]egister" on line 21.Screen.Recording.2024-07-08.at.10.31.28.AM.mov
Screen.Recording.2024-07-08.at.10.31.02.AM.mov
Dual label
Target:
e
in "active_item_nam[e]" on line 11.Screen.Recording.2024-07-08.at.10.36.25.AM.mov
Screen.Recording.2024-07-08.at.10.36.05.AM.mov
Unreachable target in default
Target:
(
in "read_dir[(]dir)" on line 14.Screen.Recording.2024-07-08.at.10.41.07.AM.mov
Screen.Recording.2024-07-08.at.10.40.49.AM.mov
Dual label with capital letter
This is one of the worst case scenarios, dual letters, with a capital letter. And while the actual number of key presses may be more with the optimized configuration, it still feels faster.
Target:
e
in "valu[e]" on line 24.Screen.Recording.2024-07-08.at.10.54.53.AM.mov
Screen.Recording.2024-07-08.at.10.53.09.AM.mov
Conclusion
I absolutely love this new configuration. It's feels so much faster by eliminating that one extra mental pause, reducing visual clutter, and allowing me to target any location on the screen. I now found myself using jump2d more frequently due to these improvements—it's even faster than using
f
on a single line in all but the case where there is only one of the target character.I hope others may find this useful as well.
Beta Was this translation helpful? Give feedback.
All reactions