Vim command to reset to the oldest change?
I am a Vim user and sometimes I made several changes in a file but then want to get back to the beginning and have to type :u a lot of times, so I ask you if there is a shortcut to get to the开发者_运维百科 "oldest change"?
Cheers!
Rodrigo Alves Vieira http://rodrigo3n.com | @rodrigo3n
The keystroke to undo is just u; if you're pressing :u then that's too many keys (although it works, it's four keys instead of one). Usually I would just hold down u and let auto-repeat do the trick (note that Ctrl+R
is the opposite of u
if you go too far)..
You can reload from the last saved version on disk using :e!
.
Does ':e!
' (followed by return) work for you? It gets back to the state of the edited file when it was last saved, or when you started if you've not saved yet...
You also have the :earlier
command. :help :ea
Using :e!
will get you back to the oldest change as saved. Aside from typing just u
instead of :u
, also see :h undo-redo
for help on all the undo commands.
Other options might be use a vim plugin, such as undo_tags.
You know you can use repeat counts on just about any VIM command, right?
My favorite way:
10000u
ten-thousand-undos.
Zips me back in time, usually to where I opened the file. I can see how things USED to be.
then
10000^R
then-thousand-redos
And I'm back at the end again.
You're welcome.
精彩评论