Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Vim has this, it's :earlier and :later

https://vimtricks.com/p/vimtrick-time-travel-in-vim/

    :earlier 3 – Undo the last 3 changes
    :earlier 5m – Go back to the state of the file 5 minutes ago
    :later 2 – After undoing something, redo the next 2 changes
    :later 1h – Travel forward through the change history 1 hour
Vim also stores the tree of changes, but it's a pain to access without plugins.


What a great feature!

Is the author of that feature here?

If so, I want to know how they could develop such a feature and be so quiet about it.

It's like someone baking a birthday cake and then dropping it down an abandoned well.

Just imagine how much more productive we'd all be if Vim bros were as loud as the crypto bros over the past decade!


You just need to get vim bros going. Just go "omg I hate vi so much" at a tech meetup and sit back for the fire hose of vim features to start.


It's like Cunningham's Law but with vim commands.



And in that 16 years, where was the Vim-sponsored nascar with ":earlier 39" printed on the hood in Courier New?

Shameful.

(I'm actually afraid to continue making jokes on the non-zero probability that someone here reads this and tries to start a Vimcoin...)


Another great Vim feature is persistent undo. You open a file, make modifications, save and close. You open again and the undo history is still there. You'll just have to enable that feature.. don't think it's on by default, unfortunately. Find a ~/.cache directory to store the undo history in.


This would make my life so much easier — constantly accidentally closing a file when I want to hold on to the undo history to redo something. Do you know the name of the feature/flag/setting?


This is what I have in my ~/.vimrc:

    " https://vi.stackexchange.com/questions/6/how-can-i-use-the-undofile
    if !isdirectory($HOME."/.vim")
        call mkdir($HOME."/.vim", "", 0770)
    endif
    if !isdirectory($HOME."/.vim/undo-dir")
        call mkdir($HOME."/.vim/undo-dir", "", 0700)
    endif
    set undodir=~/.vim/undo-dir
    set undofile


That's neat, and a missing part of my vimrc - making sure the directories I use exist. Since I use .cache and exclude those from backups, it's actually bit me.

I've added this thanks to you:

   call mkdir($HOME . "/.cache/vim/", "p", 0o700)
I think this avoids using the conditionals, by just using "p".


Using strictly vim for years, I'm still mind blown by the sheer amount of "don't knows" within the tool that I miss like this.

Thank you!


I think what vim has is different and better than what OP describes - it's two separate change logs, one for undo/redo and one for time-based jumping. Trying to fit both of those constructs into one list gets messy.


Came here to look for comments about VIM's `g-` and `g+` feature, was not disappointed :)


Are those the shortcuts for it? I can't believe I didn't realise vim had this.


Wait until you see what intellij can do. It can do that, while also layering it in a logical, graphical diff viewer


Vim has plugins for that. ;)

I use https://github.com/mbbill/undotree but if that's not to your taste there are many others.

e.g. https://docs.stevelosh.com/gundo.vim/


F** right off. How have I used Vim for fifteen years and not learned about this.


Haha, that made me spit my drink. :D


I rarely have to use it, but Undotree is so amazing when you need it.


I don’t doubt that IntelliJ overall is more user-friendly. But just to note, Emacs’ undo-tree can also show the diff for each change.

Edit: Screenshot (with an unusually blue Emacs theme): https://www.emacswiki.org/emacs/UndoTree#h5o-5



Visual Studio Code offers something similar in the timeline view. It's not as fine-grained, but still can be a life saver.


I have started to learn Vim about a year ago and still learning new tricks each day


Wait until you say this after 10 years.


After 10 years he might even be as fast as with a non-modal editor.


Every non-modal editor I’ve used is significantly slower at editing text than Vim


We have been through this argument many times. Here's Tog at Apple in 1989:

https://www.asktog.com/TOI/toi06KeyboardVMouse1.html

And even then, it was old news. There was behavioural research in the 70s, the same kind that was used for designing cockpits (and which saved lives), showing that modal interfaces were undesirable.

It can well be that you're a god with vim. But odds are, then, that you could have been a god with modern CUA-derived interfaces too (or with Emacs) if you'd put similar effort into it.


Supposedly this article has been mis-cited of late and the keyboard shortcuts / mouse shortcuts of yore are distinct from what we have today. I can't find recent links but I'll offer the general advice that words used in the 70s do not necessarily have the same connotations they carry today.

EDIT: here's an HN discussion https://news.ycombinator.com/item?id=28067729


Did you misspell "editor with language intelligence?"

Because yeah, vim won't beat IntelliJ, but you can get it to be pretty decent with LSP:

https://github.com/prabirshrestha/vim-lsp


I use vim exclusively, and I laughed, because you are sort of right.


I’m at 15 soon.


25, with 5 years of other vi editors previous to that. Vim is pretty great.


20 and I only discovered :vsplit/:hsplit this year.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: