Sunday, August 19, 2007

Vim Tip - Time based Undo (or Redo)

Well these Vim tips have really been one of the more popular topics to come through this blog in a while. I’d like to keep with tradition and keep these going each Friday. This weeks tip is reverting or redoing changes based on time, vs simply the undo command (’u') and redo command (’ctrl-r’).

From the vim :help section:

:earlier {count} Go to older text state {count} times.

:earlier {N}s Go to older text state {N} seconds before.

:earlier {N}m Go to older text state {N} minutes before.

:earlier {N}h Go to older text state {N} hours before.

Also supported is the :later command following the same syntax pattern. Easily revert to changes at previous times with the :earlier, or re-do changes forward with :later. Of course :later won’t read your mind and create your document for you, but once you’ve gone back in time you can go back to the future.

For more info on this tip type “:help earlier” within vim.

No comments: