I always work on multiple projects at the same time. The breakdown of the number of files I have is as follows
Project | Files
--------------------------
Thesis 20
Simulator 50
Plots 30
Graphs 30
Website 500+
Having all of these files in one window is cumbersome. There are several options, and I will discuss their drawbracks, or dare I say their Achilles Heel.
Split Windows I could split vim into 5 windows, one for each project, but I might as well be coding through a pinhole. I have actually never been a fan of split windows, except for cases where you are constantly comparing and editing two related files. Also I don't find navigating in two dimensions as seamless as in the horizontal direction only.
Tabs Tabs, or rather viewports foolishly called tabs, seem to be exactly for this kind of problem, but they don't provide restrictions for buffers to use. For example, if I'm in my Thesis
tab, I want to navigate only those 20 buffers, not all 500+ website related buffers as well. As I am saving these as sessions, it could potentially lead to problems if I accidentally switch to a website
buffer in my Thesis
tab, exit, then upon entering I have two website
tabs. This is further problematic because I have set local directories (:lcd
) for each tab.
Terminal Tabs Using the Terminal tabs ensures that that buffers in each tab remain independent. However, each vim session can no longer share information. I can't yank text from one terminal to the other (I suppose I could yank into the +
register). I also can no longer use :buffdo
on all the buffers. Also, I like the fact that I can save all of my vim tabs to a single session.
I know SO is anathema to public discussion, so I will instead ask if there exists a way to achieve the functionality I am striving for.
EDIT A good way to summarize what I need is to say that I want "sub buffers".
EDIT What I want to get out of the tabs in vim is the ability to more effectively use them as what they really are: viewports. I want to be able to have one tab exclusively for my Thesis section. In this section I will change the local directory to reflect it. Furthermore, I want to filter out the buffers in that table to only be a subset of all the buffers. Similarly in the Simulator tab I want to use it exclusively for my Simulator files.
Essentially what I want is the ability, through tabs, to run multiple independent sessions of vim, but still with some of the added perks (ie. sharing registers to be able to yank)
I found out a way to do this. The vim tabs are near useless. Instead I used the Gnome Terminal Tabs.
global registers To simulate using global registers, so as to be able to copy paste across different instances of vim, 'pipe' the system clipboard and the unnamed register together by adding the line set clipboard=unnamedplus
to your .vimrc file. This has the effect of all yank/delete... operations being copied to the system clipboard. From there, other instances of vim will have access to it. Similarly, any copy pasting you do outside of vim, will now be stored in the unnamed register.
Gnome Terminal Tab Shortcuts The default shortcuts for going to the next and previous tabs are Ctrl Pg Up and Ctrl Pg Dn. Since I use Shift k and Shift j for my next and previous buffers, I mapped Ctrl k and Ctrl j to go to my next and previous tabs. Simply go to the Gnome Terminal > Edit > Keyboard Shortcuts
Gnome Terminal Tabs Write a shell script to launch each vim instance as a new terminal tab. See here for instructions
Vim Instances Finally, for each vim instance save a session file :mksession fileName
It's not perfect (for example, named registers can not be copied across terminals) but it is, in my opinion, much more representative of what a viewport (here called 'tabs') should do.
EDIT I have actually gone back to using vim tabs. I learned vim script, and mapped my keys so ShiftJ and ShiftK map to previous/next buffers and CtrlJ and CtrlK map to previous/next tabs. Then I downloaded the tabname script so I could set meaningful tab names, then modified the making of vim sessions to save tab names (see here), then switched from gVim back to Vim so I could use the full screen mode. It was a long arduous journey, but I'd like to think it was worth it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With