News for hackers. Stuff that matters.
Re:Why is it so hard to see code from 5 minutes ago? by nexthash on Thursday February 18, 2021 @08:42PM (#26188452)
This is excellent... for Vim users. A lot of developers either are not willing or haven't gotten around to learning the complexities of Vim, and use other IDEs like JetBrains or Eclipse. This workflow won't work for them.
Re:Why is it so hard to see code from 5 minutes ago? by enobrev on Thursday February 18, 2021 @08:53PM (#26188544)
JetBrains' various apps can do this as well with a feature called "Show Local History". I'm not sure where it is in the menus but you can hit shift twice and type it in.

It automatically commits after every change since the IDE was opened, and can easily be diffed and reverted as needed. Reverting saves another entry, so you can revert back to the future as well.

Re:Why is it so hard to see code from 5 minutes ago? by voodootrucker on Thursday February 18, 2021 @09:37PM (#26188891)
This. I've seen developers _think_ they lost code in Android Studio and spend hours trying to recreate it when it was in local history all along...
Re:Why is it so hard to see code from 5 minutes ago? by Quekid5 on Thursday February 18, 2021 @09:01PM (#26188603)
It's in the context menu for files/classes at least.
Re:Why is it so hard to see code from 5 minutes ago? by cmehdy on Thursday February 18, 2021 @09:48PM (#26188991)
IIRC you can right-click on the column with line numbers to the left of the main editor and you'll have that option too
Re:Why is it so hard to see code from 5 minutes ago? by watwut on Friday February 19, 2021 @03:24AM (#26190834)
Eclipse has the same thing.
Re:Why is it so hard to see code from 5 minutes ago? by alpaca128 on Friday February 19, 2021 @02:49AM (#26190658)
If you learn Vim like anything else - slowly and starting with the basics - it's not more complicated than figuring out any IDE. And once you know the basics you are fully in control how deep you want to go.

Personally I have found Vim more approachable than IDEs actually. It doesn't throw all those overloaded toolbars at you according to some one-size-fits-all principle. For me it went so far that last year I actually did a Java project in Vim instead of an IDE for the first time, because the latter had grown to be so frustrating to use.

Re:Why is it so hard to see code from 5 minutes ago? by 112 on Friday February 19, 2021 @04:50AM (#26191298)
If writing text more than 4 hours / day is what you do for a living, and you have at least 10 more years left of doing that, not learning Vim is just lazy. Vim gives you back enough time to think about what you're writing.

Also, if you go cold turkey, you'll be productive in less than a month, and arrive at a good workflow that fits you in less than six months, flow that you will improve over the years in amazing ways.

Re:Why is it so hard to see code from 5 minutes ago? by hnlmorg on Friday February 19, 2021 @05:33AM (#26191558)
And there are a lot of people, like myself, who do use vim regularly and somehow completely missed this feature. For those people the OPs post is excellent.

Likewise, if you have any recommendations for your preferred workflow I'm sure some will find it useful. Hopefully those who don't use your preferred $EDITOR don't then rush to complain that not everyone uses $EDITOR. ;)

Re:Why is it so hard to see code from 5 minutes ago? by ramraj07 on Thursday February 18, 2021 @09:05PM (#26188633)
I am one of those "not willing" people. I encounter the same issue discussed here without even thinking about it, and solve it as such:

1. Realize I need to check how my new code looked like 5 min back. 2. Copy full file into clipboard, undo by a few steps 3. Do a temp commit on GitHub desktop 4. Paste the new code back and look at the diff on GitHub desktop, and if needed undo the temp commit from above.

Is this more clicks than the vin shortcut? Sure. But I don't have to go learn the internal tree structure representation of my text editor and spend my time in that universe. I have found a way to do what I need to with the tools I have in hand.

This is the same way how the majority of finance runs on excel when they could do better with better programing. In the end whether you get the job done in fields where you're not billed by the second is not dependent on how well you use your tools necessarily.

The other analogy is cars - for most people it's something that gets them places, for others it's a way of life if not at least a more involved proposition.

Re:Why is it so hard to see code from 5 minutes ago? by buzzerbetrayed on Thursday February 18, 2021 @09:53PM (#26189031)
> The other analogy is cars - for most people it's something that gets them places, for others it's a way of life if not at least a more involved proposition.

But if code is your way of life, which it is for many people here, it is beneficial to learn the tools that allow you to do it easier. If someone can see how their code was 5 minutes ago in a few keystrokes, they’re going to take advantage of that significantly more frequently than someone using your cumbersome method.

Re:Why is it so hard to see code from 5 minutes ago? by xyzzy_plugh on Friday February 19, 2021 @03:41AM (#26190934)
As some other comments suggest, vim is the gift that keeps on giving. I'm not going to try and convince you to use it -- do whatever you want.

But for me, every little thing I learn in vim pays off... a thousand times? Macros alone have probably saved me a cumulative few hundred hours. And with every other little thing I learn, compounds with this effect. I write macros much better than I did five years ago, but I still surely have tons of stuff to learn. No IDE will ever compete because vim is just four keystrokes away at any time, no matter where my terminal is.

Re:Why is it so hard to see code from 5 minutes ago? by pharke on Friday February 19, 2021 @05:02AM (#26191370)
Not so sure about this, I think it depends on how frequently you have to do that task. If you're doing it every day or even every week you could potentially be saving a huge amount of time and effort by using a tool that does the job well. It's sort of like using a random heavy object as a hammer, sure it's fine in a pinch if you need to occasionally hang a picture but if you're working as a carpenter it's counter productive. Comparing it to the notorious abuse of excel spreadsheets in finance is not doing the argument any favours.
Re:Why is it so hard to see code from 5 minutes ago? by flipcoder on Thursday February 18, 2021 @11:18PM (#26189658)
It's not as hard to learn as people say it is. It's just weird at first because it's modal and different than what they're used to. You can get away with using it pretty naively and still get a productivity gain.