News for hackers. Stuff that matters.
Re:History and effective use of Vim (2019) by christophilus on Friday July 29, 2022 @07:25AM (#32275578)
This is me all the time. The worst is “kkk”. I can’t remember why I type it in vim (it’s muscle memory, and I’m not at a computer to try it out), but it has really bad connotations here in the US south, so… no bueno.
Re:History and effective use of Vim (2019) by h0l0cube on Friday July 29, 2022 @07:41AM (#32275703)
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.

Re:History and effective use of Vim (2019) by Izkata on Friday July 29, 2022 @08:55AM (#32276243)

  :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).
Re:History and effective use of Vim (2019) by scruple on Friday July 29, 2022 @09:32AM (#32276626)
My 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.
Re:History and effective use of Vim (2019) by yjftsjthsd-h on Friday July 29, 2022 @10:49AM (#32277665)
I believe it's possible to enable relative and absolute numbers at the same time
Re:History and effective use of Vim (2019) by hajile on Friday July 29, 2022 @09:30AM (#32276596)
I also set scrolloff to 10 or so that way I can always see what's above/below what I'm currently editing.
Re:History and effective use of Vim (2019) by pge on Friday July 29, 2022 @09:58AM (#32276956)
H, 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.

Re:History and effective use of Vim (2019) by benrow on Friday July 29, 2022 @07:53AM (#32275791)
I 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.
Re:History and effective use of Vim (2019) by AdieuToLogic on Friday July 29, 2022 @08:39AM (#32276123)
> 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

Re:History and effective use of Vim (2019) by Macha on Friday July 29, 2022 @01:25PM (#32279642)
{ / } 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.

Re:History and effective use of Vim (2019) by h0l0cube on Friday July 29, 2022 @07:24PM (#32282822)
I 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>)
Re:History and effective use of Vim (2019) by raverbashing on Friday July 29, 2022 @09:44AM (#32276777)
> 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

Re:History and effective use of Vim (2019) by h0l0cube on Friday July 29, 2022 @10:13AM (#32277177)
Every 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
Re:History and effective use of Vim (2019) by chasd00 on Friday July 29, 2022 @10:22AM (#32277296)
:1 to go to the top of the file, G to goto the bottom of the file
Re:History and effective use of Vim (2019) by h0l0cube on Friday July 29, 2022 @04:57PM (#32281688)
gg will take you up to the top as well
Re:History and effective use of Vim (2019) by rob74 on Friday July 29, 2022 @07:47AM (#32275746)
Not only in the US south. In Germany, there is a health insurance called "Kaufmännische Krankenkasse", and when I first saw their name abbreviated, I wondered why it was written KKH for about half a second...
Re:History and effective use of Vim (2019) by glxxyz on Friday July 29, 2022 @11:54AM (#32278544)
KKH = Kaufmännische Krankenkasse Hauptverwaltung
Re:History and effective use of Vim (2019) by galangalalgol on Friday July 29, 2022 @07:44AM (#32275722)
I always map jj to esc in my vimrc so I don't have to leave the home row. My code in vscode often fails to compile at first because lines end with ;jj
Re:History and effective use of Vim (2019) by vbrandl on Friday July 29, 2022 @11:27AM (#32278184)
Since I have no use for it, I like to globally (not just in vim) map caps to ESC.
Re:History and effective use of Vim (2019) by galangalalgol on Friday July 29, 2022 @11:41AM (#32278375)
Not a bad idea, but its still not the home row, and its a weak finger. If I wanted a pinky ginger workout I'd use emacs.

I may still try it out. But decade long habits...

Re:History and effective use of Vim (2019) by dieselgate on Friday July 29, 2022 @12:06PM (#32278674)
It’s funny to read about this because I’m sure many people have this same internal thought process when using vim
Re:History and effective use of Vim (2019) by Mildlypolite on Friday July 29, 2022 @10:27AM (#32277354)
Can I ask what kkk means?

I thought it meant that you were laughing like haha (a leas in Brazil)

I didn't know it had bad connotations

Re:History and effective use of Vim (2019) by af16090 on Friday July 29, 2022 @10:56AM (#32277764)
Re:History and effective use of Vim (2019) by Mildlypolite on Saturday July 30, 2022 @03:06PM (#32289396)
Perhaps in US but in Brazil it is common use to write kkk to laugh
Re:History and effective use of Vim (2019) by brennopost on Friday July 29, 2022 @08:02AM (#32275846)
In Brazil is just a laugh.