News for hackers. Stuff that matters.
Re:What Is the Most Valuable Thing You Can Learn in One Hour? by 02abhishekjain on Tuesday December 31, 2019 @09:03AM (#21921027)
The vim key bindings can help you write code faster and more efficiently. Try the vim plugin for vscode. It's pretty good.
Re:What Is the Most Valuable Thing You Can Learn in One Hour? by criddell on Tuesday December 31, 2019 @09:19AM (#21921130)
I'm always skeptical of this claim (and yes I do know vim fairly well). Programming isn't that much typing. For every burst of typing there's probably an equally long or longer lull where you are leaning back and looking at the screen or sketching something out on paper.

If your productivity is limited by how fast you can type then you are either a far, far better programmer than most people or your skills are being under utilized.

Re:What Is the Most Valuable Thing You Can Learn in One Hour? by xwdv on Tuesday December 31, 2019 @09:37AM (#21921225)
Vim commands are more than just typing. It’s searching, deleting, replacing, selecting, moving entire lines of code.

I can get to any location in a massive codebase within seconds. I can drop the cursor to any character I see damn near instantly. I can construct entire macros on the fly and repeat them endlessly until I’m satisfied and destroy repetitive tasks. I can move entire sections of code to anywhere else I please, just tell the line numbers and it’s done. I don’t even have to open the files. When you’re working really fast in Vim it’s easy to get a high from the amount of code you are slicing through.

In short, classical editors are like a ball and chain for developers trying to get shit done, and I cringe every time I see a developer using a mouse or trackpad while working. It’s so slow, so inefficient, I can’t stand it anymore. I need vim-like shortcuts in every application I use.

Re:What Is the Most Valuable Thing You Can Learn in One Hour? by criddell on Tuesday December 31, 2019 @10:10AM (#21921435)
You say it's more than just typing but then you go on to describe a bunch of stuff that's essentially just typing.

I think just about any modern programmer's editor can do all the things you describe. I work most of the day in Visual Studio and I know it can do all that.

For programming I think vim is handicapped somewhat because it doesn't "understand" what it's working on.

Re:What Is the Most Valuable Thing You Can Learn in One Hour? by tcoff91 on Tuesday December 31, 2019 @11:12AM (#21922029)
The great thing about vim is every IDE has a plug-in to emulate it. Why would I learn separate shortcuts for android studio and vscode when I can just install vim plugins?
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.
Re:What Is the Most Valuable Thing You Can Learn in One Hour? by agentwiggles on Tuesday December 31, 2019 @10:44AM (#21921733)
It's not so much typing that Vim helps with, it's _editing_. It's definitely not about raw text entry - it's about thinking things like "hey I want to move these 3 lines up to this spot" and being able to do that with 3 or 4 keystrokes.

The reason folks talk about feeling crippled when they use a regular editor is that you get used to things like `f(` to take you to the front of some function's arg list, or `ci{` to quickly change some block of code.

Re:What Is the Most Valuable Thing You Can Learn in One Hour? by criddell on Tuesday December 31, 2019 @11:31AM (#21922215)
> being able to do that with 3 or 4 keystrokes.

I get that. My point is that I decide to move that chunk of code after looking at the screen for 4 minutes so it doesn't matter if it's 3 or 4 keystrokes or 5 or 6.

Once you know your editor well, you aren't thinking about the keystrokes anyway. It becomes entirely automatic. There are lots of editor operations that I couldn't tell you what the keystrokes actually are without sitting at a keyboard and doing it.