vim-nerdtree-tabs.txt 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. # NERDTree and tabs together in Vim, painlessly *vim-nerdtree-tabs*
  2. *nerdtree-tabs*
  3. ## Installation
  4. 1. Copy the plugin to your vim config dir (via pathogen or any way you want).
  5. 2. Map :NERDTreeTabsToggle command to some combo so you don't have to type it.
  6. Alternatively, you can use plug-mapping instead of a command, like this:
  7. map <Leader>n <plug>NERDTreeTabsToggle<CR>
  8. 3. Celebrate.
  9. ## Features
  10. In short, this vim plugin aims at making **NERDTree feel like a true panel**,
  11. independent of tabs. That is done by keeping NERDTree synchronized between
  12. tabs as much as possible. Read on for details.
  13. ### One command, open everywhere, close everywhere
  14. You'll get a new command: `:NERDTreeTabsToggle`
  15. For the needs of most of us, this will be the only command needed to operate
  16. NERDTree. Press it once, NERDTree opens in all tabs (even in new tabs created
  17. from now on); press it again, NERDTree closes in all tabs.
  18. ### Just one NERDTree
  19. Tired of having a fully collapsed NERDTree every time you open a new tab?
  20. Vim-nerdtree-tabs will keep them all synchronized. You will get just one
  21. NERDTree buffer for all your tabs.
  22. ### Sync to the max
  23. All NERDTree windows will always have the same scroll and cursor position.
  24. ### Meaningful tab captions
  25. You know the feeling when you want to switch to *that file* and you have 8 tabs
  26. open and they are all named 'NERD_tree_1'? Won't happen again. When leaving
  27. a tab, vim-nerdtree-tabs moves focus out of NERDTree so that the tab caption is
  28. the name of the file you are editing.
  29. ### Close the file = close the tab
  30. A tab with NERDTree and a file won't hang open when you close the file window.
  31. NERDTree will close automatically and so will the tab.
  32. ### Autoopen on startup
  33. NERDTree will open automatically on GVim/MacVim startup. You can configure it
  34. to open on console Vim as well, but this is disabled by default.
  35. ## Commands and mappings
  36. Vim-nerdtree-tabs defines two commands:
  37. *:NERDTreeTabsToggle*
  38. * `:NERDTreeTabsToggle` switches NERDTree on/off for all tabs.
  39. *:NERDTreeMirrorToggle*
  40. * `:NERDTreeMirrorToggle` acts as `:NERDTreeToggle`, but smarter: When opening,
  41. it first tries to use an existing tree (i.e. previously closed in this tab or
  42. perform a mirror of another tab's tree). If all this fails, a new tree is
  43. created. **It is recommended that you always use this command instead of
  44. `:NERDTreeToggle`.**
  45. There are also plug-mappings available with the same functionality:
  46. * `<plug>NERDTreeTabsToggle`
  47. * `<plug>NERDTreeMirrorToggle`
  48. ## Configuration
  49. You can switch on/off some features of the plugin by setting global vars to 1
  50. (for on) or 0 (for off) in your vimrc. Here are the options and their default
  51. values:
  52. * `let g:nerdtree_tabs_open_on_gui_startup = 1`
  53. Open NERDTree on gvim/macvim startup
  54. * `let g:nerdtree_tabs_open_on_console_startup = 0`
  55. Open NERDTree on console vim startup
  56. * `let g:nerdtree_tabs_no_startup_for_diff = 1`
  57. Do not open NERDTree if vim starts in diff mode
  58. * `let g:nerdtree_tabs_smart_startup_focus = 1`
  59. On startup - focus NERDTree when opening a directory, focus the file if
  60. editing a specified file. When set to `2`, always focus file after startup.
  61. * `let g:nerdtree_tabs_open_on_new_tab = 1`
  62. Open NERDTree on new tab creation (if NERDTree was globally opened by
  63. :NERDTreeTabsToggle)
  64. * `let g:nerdtree_tabs_meaningful_tab_names = 1`
  65. Unfocus NERDTree when leaving a tab for descriptive tab names
  66. * `let g:nerdtree_tabs_autoclose = 1`
  67. Close current tab if there is only one window in it and it's NERDTree
  68. * `let g:nerdtree_tabs_synchronize_view = 1`
  69. Synchronize view of all NERDTree windows (scroll and cursor position)
  70. * `let g:nerdtree_tabs_synchronize_focus = 1`
  71. Synchronize focus when switching tabs (focus NERDTree after tab switch
  72. if and only if it was focused before tab switch)
  73. * `let g:nerdtree_tabs_focus_on_files = 0`
  74. When switching into a tab, make sure that focus is on the file window,
  75. not in the NERDTree window. (Note that this can get annoying if you use
  76. NERDTree's feature "open in new tab silently", as you will lose focus on the
  77. NERDTree.)
  78. * `g:nerdtree_tabs_startup_cd = 1`
  79. When starting up with a directory name as a parameter, cd into it
  80. ## Credits
  81. * The tab autoclose feature is stolen from Carl Lerche & Yehuda Katz's
  82. [Janus](https://github.com/carlhuda/janus). Thanks, guys!