1

Here's what I mean. The built in file browser :Ex and others like NERDtree and Project have the fatal flaw that they only operate inside a single tab. I use tabs heavily, and I want a file tree view that I can keep visible globally to all tabs and open files from it into new/existing tabs. Some kind of pane or detached window or what have you. Like the way kate (kde) works.

I know that there is something like this for emacs because I've used it in the past, but I don't remember what it's called.

numerodix
  • 876
  • 7
  • 20
  • 1
    I believe this is a duplicate. Check this answer: http://stackoverflow.com/questions/1979520/auto-open-nerdtree-in-every-tab/2762067#2762067 or this link http://denapo.li/blog/2011/01/vim-and-nerd-tree-always-share-the-same-tree-across-all-tabs/ for an alternative approach. Also, check this one about "tabs vs buffers" to clarify the vim's tab behavior. http://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers/103590#103590 – GmonC Jun 22 '11 at 02:00

3 Answers3

3

Probably not quite the answer you're looking for, but there's another way of thinking about tabs in vim that will help with your problem.

You can think of each tab as a 'view' into your workspace (equivalent to something like a perspective in an IDE like eclipse), and the buffer list as what would normally be tabs in other programs.

That way you can have one tab for 'single editor with NERDTree open', one tab for 'large editor', one tab for 'vertical split editor' etc, and each tab may or may not have the same buffers open.

That way you can just stick with your single layout, and use :bnext and :bprev to switch buffers sequentially along the list, or :b <approxname> to jump to a named buffer easily. If you get the unimpaired plugin, the mappings ]b and [b are also defined that map to :bnext and :bprev for easy access. The fuzzyfinder plugin also has a :FufBuffer command that lets you easily jump to an open buffer (and then either open, split open or tab open at the press of a key once you've found it with some really intuitive default bindings).

I'm a huge fan of vimcasts, and this episode has a bit more detail of the general idea I'm talking about here.

actionshrimp
  • 5,219
  • 3
  • 23
  • 26
  • Okay, but then I have a very important question. How can I have a different cwd in each tab so that I don't have to navigate from the same $PATH every time to open buffers? – numerodix Jun 21 '11 at 19:29
  • 3
    If you use the `:lcd` command, the cwd is changed for that window (either tab or split), even after changing buffers in that window. Hope that was what you meant? The full buffer list is shared between all windows and tabs though in a single vim instance though. – actionshrimp Jun 21 '11 at 19:32
  • @numerodix: you can have your working directory to b always the same as the buffer you are editing as well. http://vim.wikia.com/wiki/Set_working_directory_to_the_current_file – GmonC Jun 22 '11 at 02:03
1

I had the same problem, so I wrote this little application http://vimpal.sourceforge.net/

0

From my limited experience, Vim's tabs are not at all the same as in firefox or kate or textmate or, well, any other app. They don't represent files and you should not use them like that. Like actionshrimp said, tabs are more like views or perspectives and you can't have a window (like NERDTree) detached from a tab.

While keeping that distinction in mind you could try to detect the creation of a tab and launch NERDTree. This way you may have file explorers on every tab but these file explorers would be x instances of NERDTree, not 1 instance. I think that would lead to memory problems quickly.

I have one tab for each project I'm working on. That's consistant with what I think is the idea behind tabs and is tremendously helpful for staying organised.

romainl
  • 186,200
  • 21
  • 280
  • 313