News for hackers. Stuff that matters.
Re:Ten Years of Vim by linsomniac on Sunday May 20, 2018 @07:16PM (#17115243)
One thing google can do that blows most peoples mind when I show them: Did you know vim supports time travel undo?

Sometimes you do some things then undo and redo trying to get back to a certain point in time. In vim you can step forward and back through all this by doing "g-" or "g+" to travel backwards or forwards in time. Or you can say ":earlier 50s" to go back to where you were 50 seconds ago.

Most editors treat undo as a linear thing, you undo and you redo. But once you undo and then do some things, it starts looking more like a tree than a line. It's not frequent, but sometimes I just need to say "I know what I had was what I wanted 5 minutes ago."

Re:Ten Years of Vim by kmowery on Sunday May 20, 2018 @09:11PM (#17115598)
One of my favorite vim plugins is https://github.com/sjl/gundo.vim , which can open a pane showing the actual tree of versions, including at what time the version changed. j and k can move around in the tree, and the pane with the file will show what it was at a given time. I've definitely used it to pull out a version of a file as it existed an hour ago...
Re:Ten Years of Vim by codemac on Sunday May 20, 2018 @11:45PM (#17115990)
Undo-tree for you emacs folks: https://www.emacswiki.org/emacs/UndoTree
Re:Ten Years of Vim by giancarlostoro on Sunday May 20, 2018 @08:27PM (#17115465)
All the JetBrains IDE's keep a history of your edits, I accidentally rm -rf'd the wrong dir and reverted my code back thanks to JetBrains. I can't imagine vim saving your old files that have yet to be checked in to SVN / git (breaking changes anyone?) that you've not yet opened on vim.

Funny you mention that though, a coworker opens files in vim and does changes and tests but keeps it open if he's going to try something else so he can always go back to those other changes (guessing he reverts the code, then opens yet another vim window). I work with a lot of VI(M) coders but they barely take full advantage of VI(M). I just use IDE's or Emacs / VS Code (w/ X Forwarding more recently) personally makes it easier to find the fancy features with a UI.

I'll share that time travel feature to my VIM coworkers maybe it'll save their tail sometime.

Re:Ten Years of Vim by chongli on Monday May 21, 2018 @12:33AM (#17116153)
Vim also has persistent undo. Check out the options:

    undofile
    undodir
These will cause vim to store all file histories into files within that directory. Now you can close and reopen vim and continue undoing as much as you want!
Re:Ten Years of Vim by wildmusings on Monday May 21, 2018 @07:36AM (#17117604)
Do you know if there’s a way to make “normal undo” stop at the beginning of the current session, then have some special command or confirmation that I indeed want to move further back? I almost never want to undo past the current session, but occasionally I do.
Re:Ten Years of Vim by reitanqild on Monday May 21, 2018 @01:56AM (#17116437)
FWIW Netbeans also keeps local file history. (Nothing against Jetbrains. They seem like a great company with great products and a really nice pricing model, I just prefer Netbeans.)
Re:Ten Years of Vim by giancarlostoro on Monday May 21, 2018 @03:56AM (#17116829)
After IntelliJ I prefer NetBeans to be fair. I like JetBrains due to all the IDE's they offer me with consistent capabilities between all of them.
Re:Ten Years of Vim by williamxd3 on Sunday May 20, 2018 @11:41PM (#17115981)
Did that too, I thought history wouldn't work cause the .idea folder inside was gone, but it did. JetBrains saved me some good 5 hours of work that day.
Re:Ten Years of Vim by timrichard on Monday May 21, 2018 @06:41AM (#17117382)
It's a great feature, and I use Local History a lot. One thing to bear in mind, though, is that it will go if you invalidate caches.
Re:Ten Years of Vim by some_account on Monday May 21, 2018 @01:11AM (#17116264)
It has saved me too a couple of times. Jetbrains for the win :)
Re:Ten Years of Vim by s_m_t on Sunday May 20, 2018 @07:24PM (#17115271)
Very cool. Do you know if you can "mark" spaces in time to jump back to like you can spatially in vim? Sometimes I change a bunch of random stuff at once to try and get something to work, and perhaps this use case would be better suited to an actual git commit but I feel like a mark in time might be a good inbetween measure.
Re:Ten Years of Vim by markrian on Sunday May 20, 2018 @07:42PM (#17115330)
The closest thing I'm aware of is ":earlier {N}f", which "[Goes] to older text state {N} file writes before.".

So once you're somewhat happy with what you've got, write the file, and then continue editing, repeat, and you can revert back to any previous saved file state.

Re:Ten Years of Vim by s_m_t on Monday May 21, 2018 @12:34AM (#17116157)
Awesome, thanks
Re:Ten Years of Vim by wodenokoto on Monday May 21, 2018 @04:08AM (#17116870)
I often find my self editing line x, and then add a few lines, only to find that the edit I did on line x is now needless and I want to revert only that line.

In photoshop you have an undo paintbrush. I'd love to have something similar in my text editor.

Re:Ten Years of Vim by platz on Sunday May 20, 2018 @08:34PM (#17115492)
tell that to vs code!