News for hackers. Stuff that matters.
Re:What Is the Most Valuable Thing You Can Learn in One Hour? by OGWhales on Tuesday December 31, 2019 @02:08PM (#21923597)
I'm trying to learn vim, thanks to this thread. How do I "drop the cursor to any character I see damn near instantly."

I'm digging moving things around quickly and all that. But I don't know how to get my cursor where I want it quickly.

Re:What Is the Most Valuable Thing You Can Learn in One Hour? by tcoff91 on Tuesday December 31, 2019 @03:38PM (#21924532)
First of all, I recommend that you turn on relative line numbers AND also normal line numbers. This means that the line the cursor is on will show the absolute line number, but lines above and below will show how many lines away they are from the current line. :set relativenumber :set number

This makes it really easy to get to the line you are looking at. You look at the relative line number, see it's 9 lines above, so you start out with pressing 9k to jump up 9 lines.

Let's say you're trying to get to an instance of the 'a' character. The character is to the right of your cursor, so you press fa to jump to the next instance of the 'a' character. However, it turns out that there are multiple instances of the 'a' character before the one you are trying to get to. So you repeatedly press ; to keep going to the next 'a' character until you get to the one you want. You've accidentally passed the one you want, so you press , to go back one.

So all together you something like 9kfa;;

Also related to the f motion are the F, t, and T motions. I use the t motion all the time. t and T are like f and F but they put you on the character before the one you specify. Very useful for jumping to the first character before the next parentheses and things like that.

purely for putting the cursor exactly where you want it there are more powerful things like the emacs acejump plugin or easymotion for vim but they aren't all that necessary IMO.

Re:What Is the Most Valuable Thing You Can Learn in One Hour? by BenjiWiebe on Tuesday December 31, 2019 @10:09PM (#21926402)
I use vim exclusively for programming and general text editing, and I didn't know about relative line numbers! Thanks a lot, I think that's going to be in my .vimrc!
Re:What Is the Most Valuable Thing You Can Learn in One Hour? by OGWhales on Wednesday January 01, 2020 @01:49PM (#21929720)
Super awesome! Thank you so much, this is extremely helpful.