4 ms·
Unsolicited advice for scrolling without spamming j and k: - C-u and C-d to jump up/down - [ and ] to go prev/next empty line (I have a macro to clear empty s
by h0l0cube 4y ago
Unsolicited advice for scrolling without spamming j and k:
- C-u and C-d to jump up/down
- [ and ] to go prev/next empty line (I have a macro to clear empty spaces at the end of lines so this works well for jumping functions in code)
- from the article: 50% to go the halfway point of a document
- 100gg to go to line 100
- 100k to go 100 lines down
Are there any more good ones?
Edit: occurs to me that you might have remapped kkk to escape normal mode. At one time I had done this for jj. Now I just use C-[ as it’s portable to vanilla vim setups and less of a stretch than the escape key.
- benrow 4y agoI like using L and H to go to bottom or top of screen to initiate scrolling with j or k. You can scroll up or down without moving the cursor using Ctrl-Y and Ctrl-E but I find those a bit hard to get used to.
- AdieuToLogic 4y ago> Are there any more good ones? I find these handy, especially after doing a search (quoted from :h z): - z. redraw, cursor line to center of window - z<CR> redraw, cursor line to top of window - z- redraw, cursor line at bottom of window
- Izkata 4y ago:set relativenumber The line the cursor is on is now shown in the left sidebar as 0, counting up for each line away from the cursor. So now it tells you what number to use for "10j" and "10k" to move up and down a specific number of lines. m[a-z] `[a-z] Mark a point in a file into a register, and jump back to that point. Or even more interesting: m[A-Z] `[A-Z] Same as above, except capital marks are global and work across files. Also, `` Jump back to the last place you jumped from (but only within the same file).
- hajile 4y agoI also set scrolloff to 10 or so that way I can always see what's above/below what I'm currently editing.
- scruple 4y agoMy only problem with relative line numbers (and I use them despite this) is working with ranges of line numbers. For instance, I'll maybe be doing some refactoring and want to see what it looks like to move lines 127,137 to my current cursor (127,137t.). With relative line numbers I have to do some quick arithmetic to sort out the range.
- yjftsjthsd-h 4y agoI believe it's possible to enable relative and absolute numbers at the same time
- raverbashing 4y ago> advice for scrolling without spamming j and k Or just use the directional keys and PgUp/PgDown like any person in the last 30 yrs
- h0l0cube 4y agoEvery time my fingers have to leave the home row I feel pain. Mostly from knowing that I’m likely to typo straight after, or have to remove my gaze from the screen to check my fingers and then find my position on the screen again. It really breaks flow and that flow was a big motivation for me to start using vim
- pge 4y agoH, M, and L will move the cursor to the top, middle and bottom (respectively) of the screen. That is, H moves the cursor to the top visible line on the screen, L to the last line currently visible, and M to the middle. Cursor moves but text does not. zt, zz, and zb are similar but move the text not the cursor. So, zt will take the current line the cursor is on and make it the first visible line on the screen (and keep the cursor on that line). zz to the middle, zb to the bottom. Personally, I use [ and ] to jump around most often in code, but the above are handy when you are working with documents.
- chasd00 4y ago:1 to go to the top of the file, G to goto the bottom of the file
- h0l0cube 4y agogg will take you up to the top as well
- Macha 4y ago{ / } jump to start/end of the block. Between that and 20j and (blasphemy probably) just using the scroll wheel, that handles most of my scrolling needs.
- h0l0cube 4y agoI think I meant to write { and } (which is previous/next empty line) instead of [ and ] which can be combined like [( ]) or [{ ]} to go to the beginning and end of parentheses and curly brackets respectively. % is good for jumping between matching parenthesis... I wish there was something like this for *ml tags inbuilt (e.g., go to matching <div> <-> </div>)