3 ms·
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 r
by linsomniac 8y ago
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."
- s_m_t 8y agoVery 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.
- markrian 8y agoThe 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.
- s_m_t 8y agoAwesome, thanks
- giancarlostoro 8y agoAll 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.
- williamxd3 8y agoDid 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.
- chongli 8y agoVim 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!
- marcoperaza 8y agoDo 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.
- some_account 8y agoIt has saved me too a couple of times. Jetbrains for the win :)
- reitanqild 8y agoFWIW 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.)
- giancarlostoro 8y agoAfter 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.
- timrichard 8y agoIt'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.
- platz 8y agotell that to vs code!
- kmowery 8y agoOne of my favorite vim plugins is https://github.com/sjl/gundo.vim 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...
- codemac 8y agoUndo-tree for you emacs folks: https://www.emacswiki.org/emacs/UndoTree https://www.emacswiki.org/emacs/UndoTree
- wodenokoto 8y agoI 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.