Giter Club home page Giter Club logo

undotree.vim's Introduction

Link to Vim.org

Screenshot

Description

Vim 7.0 added a new feature named Undo branches. Basically it's a kind of ability to go back to the text after any change, even if they were undone. Vim stores undo history in a tree which you can browse and manipulate through a bunch of commands. But that was not enough straightforward and a bit hard to use. You may use :help new-undo-branches or :help undo-tree to get more detailed help. Now this plug-in will free you from those commands and bring back the power of undo tree.

Features

  1. Visualize undo-tree
    • The undo history is sorted based on the changes' timestamp. The year/month/day field will not be displayed if the changes were made within the same day.
    • The change sequence number is displayed before timestamp.
    • The current position is marked as >seq<.
    • The next change that will be restored by :redo or <ctrl-r> is marked as {seq}, it's the same as curhead returned by undotree()
    • The [seq] marks the last change and where further changes will be added, it's the same as newhead returned by undotree()
    • Saved changes are marked as s and the capitalized S indicates the last saved change.
  2. Live updated diff panel.
  3. Highlight for added and changed text.
  4. Revert to a specific change by a single mouse click or key stroke.
  5. Customizable hotkeys and highlighting.
  6. Display changes in diff panel.

Download

Install

  1. Unpack all scripts into .vim directory and that's all. This script is written purely in Vim script with no additional dependency.
  2. It's highly recommend using pathogen or Vundle to manage your plug-ins.

Usage

  1. Use :UndotreeToggle to toggle the undo-tree panel. You may want to map this command to whatever hotkey by adding the following line to your vimrc, take F5 for example.

    nnoremap <F5> :UndotreeToggle<cr>

  2. Then you can try to do some modification, and the undo tree will automatically updated afterwards.

  3. There are a bunch of hotkeys provided by vim to switch between the changes in history, like u, <ctrl-r>, g+, g- as well as the :earlier and :later commands.

  4. You may also switch to undotree panel and use the hotkeys to switch between history versions. Press ? in undotree window for quick help of hotkeys.

  5. You can monitor the changed text in diff panel which is automatically updated when undo/redo happens.

  6. Persistent undo

    • It is highly recommend to enable the persistent undo. If you don't like your working directory be messed up with the undo file everywhere.

Add the following line to your vimrc in order to make them stored together.

if has("persistent_undo")
    set undodir = '/path/to/what/you/want/'
    set undofile
endif

Configuration

  1. Basically, you do not need any configuration to let it work, cool?
  2. But if you still want to do some customization, there is also a couple of options provided.
    • Here is a list of these options.

Post any issue and feature request here:

https://github.com/mbbill/undotree/issues

Debug

  1. Create a file under $HOME with the name undotree_debug.log
    • $touch ~/undotree_debug.log
  2. Run vim, and the log will automatically be appended to the file, and you may watch it using tail:
    • $tail -F ~/undotree_debug.log
  3. If you want to disable debug, just delete that file.

Alternatives

Someone asked me about the difference with Gundo, here is a list of differences, or advantages.

  1. Pure vimscript implementation and no 3rd-party libraries(like python) is needed, don't worry about performance, it's not such a big deal for vim to handle this. The only dependency is the 'diff' tool which always shipped with vim and even without 'diff' you still can use most of the features of this script.
  2. Realtime updated undo tree. Once you make changes, the undo tree will be updated simultaneously.
  3. Several useful marks, like current changeset, next redo changeset, saved changeset, etc.
  4. Toggle between relative timestamp and absolute timestamp.
  5. Realtime updated undo window.
  6. Ability to clear undo history.
  7. More customizable.

License

BSD

Author

Ming Bai <mbbill AT gmail DOT COM>

undotree.vim's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.