4 ms·
> Go down 5 lines Look at the beginning of a target line, remember the number (takes up a slot in our limited short-term memory), switch to command mode, type
by red75prime 6y ago
> Go down 5 lines
Look at the beginning of a target line, remember the number (takes up a slot in our limited short-term memory), switch to command mode, type the command.
vs
Hold/mash "down" button until cursor is there.
After watching a few vim coding screen-casts I have the impression that the second way is more popular in vim too.
- L3viathan 6y ago> switch to command mode Why? Just use the 'relativenumber' option and do 5j. > the second way is more popular in vim too. Maybe for moving down 5 lines, but (I hope) not for things like "replace the inside of the brackets with what's in my A register". Otherwise you're really better off using a different editor.
- red75prime 6y ago> Why? To be sure that the editor isn't in insert mode. Using another slot of short-term memory to keep an editor's mode seems wasteful.
- theon144 6y agoContrary to popular techy opinion, short-term memory is not composed of hard, fixed "slots" that fill up and overflow. It's not like remembering one more byte of information will make a variable name fall out of your memory on the other end. Besides, it might just as well become something you don't need to use memory for at all - just press Esc to make sure. If you're in command mode, nothing happens. If you're in insert mode, you've entered command mode.
- red75prime 6y ago> short-term memory is not composed of hard, fixed "slots" that fill up and overflow. Nevertheless it is a limited resource. > just press Esc to make sure It's better to press Esc twice. Otherwise there's a risk of terminal emulator interpreting a command as an escape sequence.
- boogies 6y agoTBH I think I almost never look at the line numbers in vi, but the alternative isn't always holding/mashing j. I occasionally use a count (5j to move 5 lines down, especially good for moving ~4 lines at a time), sometimes use C-u/d, C-f/b, or H/L to scroll half a page up/down, a full page up/down, or move the cursor to the Highest/Lowest line on the screen (these are good for large movement. And you can use zz to recenter the cursor on the screen after H/L). But likely the most common vertical movement I use is curly brackets/braces to move a paragraph up/down. In CUA editors to me the nicest shortcuts are Control[+Shift]+Backspace and Control[+Shift]+Arrow because they involve the editor understanding a basic construct of human language (words). Vi takes that to the next level.