1
0

gundo.txt 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. *gundo.txt* Graph your undo tree so you can actually USE it.
  2. Making Vim's undo tree usable by humans.
  3. ==============================================================================
  4. CONTENTS *Gundo-contents*
  5. 1. Intro .......................... |GundoIntro|
  6. 2. Usage .......................... |GundoUsage|
  7. 3. Configuration .................. |GundoConfig|
  8. 3.1 gundo_width ............... |gundo_width|
  9. 3.2 gundo_preview_height ...... |gundo_preview_height|
  10. 3.3 gundo_preview_bottom ...... |gundo_preview_bottom|
  11. 3.4 gundo_right ............... |gundo_right|
  12. 3.5 gundo_help ................ |gundo_help|
  13. 3.6 gundo_disable ............. |gundo_disable|
  14. 3.7 gundo_map_move_older ...... |gundo_map_move_older|
  15. gundo_map_move_newer ...... |gundo_map_move_newer|
  16. 3.8 gundo_close_on_revert ..... |gundo_close_on_revert|
  17. 3.9 gundo_preview_statusline .. |gundo_preview_statusline|
  18. gundo_tree_statusline ..... |gundo_tree_statusline|
  19. 4. License ........................ |GundoLicense|
  20. 5. Bugs ........................... |GundoBugs|
  21. 6. Contributing ................... |GundoContributing|
  22. 7. Changelog ...................... |GundoChangelog|
  23. 8. Credits ........................ |GundoCredits|
  24. ==============================================================================
  25. 1. Intro *GundoIntro*
  26. You know that Vim lets you undo changes like any text editor. What you might
  27. not know is that it doesn't just keep a list of your changes -- it keeps
  28. a goddamed |:undo-tree| of them.
  29. Say you make a change (call it X), undo that change, and then make another
  30. change (call it Y). With most editors, change X is now gone forever. With Vim
  31. you can get it back.
  32. The problem is that trying to do this in the real world is painful. Vim gives
  33. you an |:undolist| command that shows you the leaves of the tree. Good luck
  34. finding the change you want in that list.
  35. Gundo is a plugin to make browsing this ridiculously powerful undo tree less
  36. painful.
  37. ==============================================================================
  38. 2. Usage *GundoUsage*
  39. We'll get to the technical details later, but if you're a human the first
  40. thing you need to do is add a mapping to your |:vimrc| to toggle the undo
  41. graph: >
  42. nnoremap <F5> :GundoToggle<CR>
  43. Change the mapped key to suit your taste. We'll stick with F5 because that's
  44. what the author uses.
  45. Now you can press F5 to toggle the undo graph and preview pane, which will
  46. look something like this: >
  47. Undo graph File
  48. +-----------------------------------+------------------------------------+
  49. | " Gundo for something.txt [1] |one |
  50. | " j/k - move between undo states |two |
  51. | " <cr> - revert to that state |three |
  52. | |five |
  53. | @ [5] 3 hours ago | |
  54. | | | |
  55. | | o [4] 4 hours ago | |
  56. | | | | |
  57. | o | [3] 4 hours ago | |
  58. | | | | |
  59. | o | [2] 4 hours ago | |
  60. | |/ | |
  61. | o [1] 4 hours ago | |
  62. | | | |
  63. | o [0] Original | |
  64. +-----------------------------------+ |
  65. | --- 3 2010-10-12 06:27:35 PM | |
  66. | +++ 5 2010-10-12 07:38:37 PM | |
  67. | @@ -1,3 +1,4 | |
  68. | one | |
  69. | two | |
  70. | three | |
  71. | +five | |
  72. +-----------------------------------+------------------------------------+
  73. Preview pane
  74. Your current position in the undo tree is marked with an '@' character. Other
  75. nodes are marked with an 'o' character.
  76. When you toggle open the graph Gundo will put your cursor on your current
  77. position in the tree. You can move up and down the graph with the j and
  78. k keys.
  79. You can move to the top of the graph (the newest state) with gg and to the
  80. bottom of the graph (the oldest state) with G.
  81. As you move between undo states the preview pane will show you a unified diff
  82. of the change that state made.
  83. Pressing enter on a state (or double clicking on it) will revert the contents
  84. of the file to match that state.
  85. You can use p on a state to make the preview window show the diff between
  86. your current state and the selected state, instead of a preview of what the
  87. selected state changed.
  88. Pressing P while on a state will initiate "play to" mode targeted at that
  89. state. This will replay all the changes between your current state and the
  90. target, with a slight pause after each change. It's mostly useless, but can be
  91. fun to watch and see where your editing lags -- that might be a good place to
  92. define a new mapping to speed up your editing.
  93. Pressing q while in the undo graph will close it. You can also just press your
  94. toggle mapping key.
  95. ==============================================================================
  96. 3. Configuration *GundoConfig*
  97. You can tweak the behavior of Gundo by setting a few variables in your :vimrc
  98. file. For example: >
  99. let g:gundo_width = 60
  100. let g:gundo_preview_height = 40
  101. let g:gundo_right = 1
  102. ------------------------------------------------------------------------------
  103. 3.1 g:gundo_width *gundo_width*
  104. Set the horizontal width of the Gundo graph (and preview).
  105. Default: 45
  106. ------------------------------------------------------------------------------
  107. 3.2 g:gundo_preview_height *gundo_preview_height*
  108. Set the vertical height of the Gundo preview.
  109. Default: 15
  110. ------------------------------------------------------------------------------
  111. 3.3 g:gundo_preview_bottom *gundo_preview_bottom*
  112. Force the preview window below current windows instead of below the graph.
  113. This gives the preview window more space to show the unified diff.
  114. Example:
  115. +--------+ +--------+
  116. !g! ! ! !g!
  117. !g! ! or ! !g!
  118. !g!______! !______!g!
  119. !g!pppppp! !pppppp!g!
  120. +--------+ +--------+
  121. Default: 0
  122. ------------------------------------------------------------------------------
  123. 3.4 g:gundo_right *gundo_right*
  124. Set this to 1 to make the Gundo graph (and preview) open on the right side
  125. instead of the left.
  126. Default: 0 (off, open on the left side)
  127. ------------------------------------------------------------------------------
  128. 3.5 g:gundo_help *gundo_help*
  129. Set this to 0 to disable the help text in the Gundo graph window.
  130. Default: 1 (show the help)
  131. ------------------------------------------------------------------------------
  132. 3.6 g:gundo_disable *gundo_disable*
  133. Set this to 1 to disable Gundo entirely.
  134. Useful if you use the same ~/.vim folder on multiple machines, and some of
  135. them may not have Python support.
  136. Default: 0 (Gundo is enabled as usual)
  137. ------------------------------------------------------------------------------
  138. 3.7 g:gundo_map_move_older, g:gundo_map_move_newer *gundo_map_move_older*
  139. *gundo_map_move_newer*
  140. These options let you change the keys that navigate the undo graph. This is
  141. useful if you use a Dvorak keyboard and have changed your movement keys.
  142. Default: gundo_map_move_older = "j"
  143. gundo_map_move_newer = "k"
  144. ------------------------------------------------------------------------------
  145. 3.8 g:gundo_close_on_revert *gundo_close_on_revert*
  146. Set this to 1 to automatically close the Gundo windows when reverting.
  147. Default: 0 (windows do not automatically close)
  148. ------------------------------------------------------------------------------
  149. 3.9 g:gundo_preview_statusline *gundo_preview_statusline*
  150. g:gundo_tree_statusline *gundo_tree_statusline*
  151. Set these to a string to display it as the status line for each Gundo window.
  152. Default: unset (windows use the default statusline)
  153. ==============================================================================
  154. 4. License *GundoLicense*
  155. GPLv2+. Look it up.
  156. ==============================================================================
  157. 5. Bugs *GundoBugs*
  158. If you find a bug please post it on the issue tracker:
  159. http://bitbucket.org/sjl/gundo.vim/issues?status=new&status=open
  160. ==============================================================================
  161. 6. Contributing *GundoContributing*
  162. Think you can make this plugin better? Awesome. Fork it on BitBucket or GitHub
  163. and send a pull request.
  164. BitBucket: http://bitbucket.org/sjl/gundo.vim/
  165. GitHub: http://github.com/sjl/gundo.vim/
  166. ==============================================================================
  167. 7. Changelog *GundoChangelog*
  168. v2.3.0
  169. * Add statusline configuration.
  170. v2.2.2
  171. * More performance improvements.
  172. v2.2.1
  173. * Refactoring and performance improvements.
  174. v2.2.0
  175. * Add the g:gundo_close_on_revert setting.
  176. * Fix a bug with the splitbelow setting.
  177. v2.1.1
  178. * Fix a bug with the movement key mappings.
  179. v2.1.0
  180. * Warnings about having an incompatible Vim and/or Python installation
  181. are now deferred until the first time you try to use Gundo, instead
  182. of being displayed on launch.
  183. * The <j> and <k> mappings are now configurable with
  184. g:gundo_map_move_older and g:gundo_map_move_newer.
  185. * The o, <Up> and <Down> keys are now mapped in the Gundo pane.
  186. * Improve and add several unit tests for Gundo.
  187. v2.0.0
  188. * Make GundoToggle close the Gundo windows if they're visible but not the
  189. current window, instead of moving to them.
  190. * Add the g:gundo_help setting.
  191. * Add the g:gundo_disable setting.
  192. * Add the 'p' mapping to preview the result of reverting to the selected
  193. state.
  194. * Fix movement commands with counts in the graph.
  195. v1.0.0
  196. * Initial stable release.
  197. ==============================================================================
  198. 8. Credits *GundoCredits*
  199. The graphing code was all taken from Mercurial, hence the GPLv2+ license.
  200. The plugin was heavily inspired by histwin.vim, and the code for scratch.vim
  201. helped the author get started.
  202. ==============================================================================