I’ve been using vim for 10+ years. However I honestly don’t see the downside of repeating h or j to move up/down (with the key repeat delay adjusted to a small value). It’s more intuitive than using say 15j, which involves recognizing some number in the screen and then look at the keyboard to type because the upper number row cannot be easily touch typed

I was the exact same until I started using relative line numbers. Then I can just look at a line and see that it's N lines down and jump there immediately. With j or k repeat I'll often over shoot and then have to go back which is kind of annoying.

How is this easier than jumping straight to the line with absolute numbers?

15j is easier than 4879gg. It’s a little bit quicker on big files—not a huge difference.

The information is also more relevant. How many lines a function or block has might make a difference, but the absolute file position is, more often than not, irrelevant.

Funny, I was thinking exactly the opposite. Stack traces, logs, test failures, warning, etc will always reference an absolute number. If you want to tell a coworker where to find a section of code, you use the absolute number.

Relative numbers are useful to save a few keystrokes. But in every other context, absolute numbers are what's relevant.

[deleted]

Did you get better in maths?

C-d, C-u, {}, () and searches are better anyway. You should also be using g, so say you are defining a function and need to check where it's going to be used on main. For optimal usage you should always have main marked as something, so you would exit insert mode, gm, look around in main, gi to go back to where you were typing last

Exactly. h or j repeated is widely dismissed as inefficient. But that ignores two important things:

First, you can hold down h or j and use visual clues to know when to stop. It's one keypress on the homerow, no reason to even glance at the keyboard. Eyes on the monitor = better focus. One keystroke.

Second, thinking in line numbers is one more piece of context to load up into your brain (find the line number), then act on (type out incantation), then context switch back to whatever you were doing before. By contrast, holding j until you're in the spot takes up almost zero working memory. You can think while it's happening! It's a small and subtle difference but that 200ms pause in thought process really does add up - not in wall time (jumping by line is probably "faster") but in contiguous focus time. Having to invoke any multi-part command is a distraction from your core work. Again, one lazy keystroke with immediate visual feedback > some complex combination of keystrokes.

An one small pitch for treesitter - rather than use j/k to navigate by line, set up some keybindings to jump by treesitter element (functions, methods, etc). I've got mine set to +/-. This lets you move in the same "dumb scrolling" way but by jumping to semantically-relevant parts automatically rather than line by line.

Agreed. I wonder if this is somewhat revealing of the mental processes of the creators.

To me, if my cursor is a few lines away from another line, the easiest way for me to get there is by either using h/j a few times, or looking at the absolute line number and doing that with gg.

Relative jumps are only useful to me in macros. Calculating a relative jump myself would 100% pull me out of the flow state where I just want to go up/down a few rows.

I have no proof of this, but I’d guess that the creator of this pattern didn’t feel the same way.

The best tip I got, was to rely more on search instead of other kind of movement. Especially when doing a bunch of editing. Things like easymotion/sneak/avy works best when reading/reviewing.

While I loved multi cursor with sublime. After I moved to Vim, I’ve never needed it. It’s either search~repeat or a macro. Now I’m using emacs, and it’s mostly occur-mode and macro. Grep edit is nice for bigger refactoring.

I really, really like flash/easymotion/etc because I effectively also use the same jump motions all the time in my browser (with vimium/tridactyl). So I have double the muscle memory, and I context-switch less between my browser and neovim, compared to if I was primarily using relative line jumps in neovim

Why’d you switch to emacs, and do you use evil mode?

Vim is a fine editor, but emacs has better tooling. I got in touch with Emacs while learning Common Lisp, and I got hooked by the extensive capabilities and customization available. Vim is fine for extension, but you have to build most of them yourself.

I tried evil mode, but it clashes with other keybinding in some places and I got unhappy with it. There's a philosophy conflict there. With vim, you're expected to have a command for an action and then bind it to a key. Your editing workflow is to compose those keys.

But with emacs, you're more expected to have a view and then a set of actions for that view. The power of emacs comes with how easy it is to integrate all those views together. For a programming workflow, you have the file explorer, the symbol explorer, the search result (single file and all files), the version control, the docs, the compilation|build window, the shell, the project tasks,... all together in the same place and linked to each other. With vim, you have to compose all those with a multiplexer and other tools (with conflicting bindings) to get there. Vim is still better for editing, but Emacs is better for workflows.

Why would you ever calculate relative jump yourself instead of having relative line numbers in the gutter?

And yes, for a few lines it's fine, the plugin has this number configurable.

Thanks for letting me know, I wasn’t aware that was possible!

Getting used to thinking about multi-line motions via 5j helped me train to visualise lines that way.

Over time, I started using things like 13dd or 7yy with more ease.

Of course, `set relativenumber` is always recommended.

> Calculating a relative jump myself would 100% pull me out of the flow state where I just want to go up/down a few rows.

Yeah, you can't be a purist about it. If you're hard-focused and jjjjj is the first thing that comes to mind, then that's fine. When you're doing lighter work is when you have the spare mental capacity to train and improve on your workflow.

There are countless more convenient keys that you can use to navigate up and down without counting. Basic ones are /, *, n, N, H, M, L, {, }, %, ctrl-]. ]c, [c when you're in a diff buffer or have a Git plugin that offers this key. ]d, [d, [q, ]q, ]l, [l if you use Neovim.

It's nice to have good tools that are practical for navigating around the text.

For jumping around what's on screen, I think 'easymotion' ("jump anywhere on screen by pressing two characters") & variations are best in terms of how quickly they let you navigate for how easy it is to use.

You don't need to use the upper row, bind numbers to right thumb modifier + numpad-like uio jkl m,.

Or instead of 15j use another jump to command that accepts those letters as numbers

Or have some jump type of command that displays a-z labels 1 per row in the middle and you can jump without numbers and without shifting focus to the gutter

But yes, the most basic motion will still be more "intuitive"

Huh, I don't find the number row very difficult to touch type. But then again, I do have long fingers.

I've pretty much always struggled with this too. I have a numpad that I can touchtype easily but if I'm taking my hands off homerow I may as well use a mouse at that point.

Also gives me time to plan what I'm going to do once I get there. Or I spot a bug/relevant code snippet along the way.