Vim Tips Wiki
Advertisement

For basic tab use, see part one: Introduction to using tab pages.

The following is a copy-paste of ideas from a thread on vim_use. Some of these may spawn a new tip or two:

  • Multiple full-page Vim help topics, each in their own conveniently-labeled tab page.
  • Reference material (API docs, framework source code, project notes, etc.) that I need to refer to often, but don't necessarily want taking up screen real estate adjacent to whatever I'm working on.
  • At-a-glance summaries: I sometimes work in a buffer with most or all folds open, and keep a second tab page buffer with all folds closed. The folded version serves as an overview of the entire file, usually visible on a single screen.
This is a very interesting idea which I hadn't thought of and may use myself. It could lead to other use cases; for example, rapidly finding a place in a file, setting a mark (local to the buffer), and jumping to it in another window/tab. I'm not sure where to put it. It seems a little small for a tip by itself. It would probably be OK in the intro to tab-pages tip, or perhaps a folding tip. It potentially could be included with your "X-Ray tab" tip below.
  • Quick Vim environment modifications: I'm always tweaking my Vim settings, but I don't want to disrupt whatever I'm (supposed to be) working on just to update my .vimrc. I have a key map that opens $MYVIMRC and $MYGVIMRC in new tabs, so I can jump in and make whatever changes are necessary, then close them and immediately go back to what I was doing.
  • "X-ray" buffers: I'll sometimes keep an alternate representation of a buffer in a separate tab page, with useful but visually-noisy options like 'list', 'cursorcolumn', 'cursorline', and 'number' all turned on, several :match patterns active, etc. This way, I can keep my regular working view clean and uncluttered, but quickly flip over to the information-overload version (the "x-ray") when I need it. (You don't have to get this crazy with it, of course; the idea works for pretty much any setting in `:help option-summary` labeled 'local to window'.)
I really like this one. The idea is very basic, but perhaps with some expansion--some pre-made commands, etc.--it could make a tip on its own. I think it deserves more than a short section in an "intro to tabs" tip. Of course, it could be done in the same window with the ability to restore the window-local settings, or a split window, so these techniques should be mentioned as well. But I like that the tab page doesn't take up additional screen real estate, and you don't need to worry about restoring the state of the window when you're done.
  • Scratchpads: Tab pages are good for throwaway buffers, where I work with random chunks of text before (possibly) incorporating them into a file I plan to keep around.
  • Redirected Ex command output: I often want to use the output from an Ex command (vs. just viewing it in the status area), so I have a routine that runs a command, captures the output, then opens a new tab page containing the captured text. As with most of these techniques, this could also be done with a new window, or even within the current window, but I find using a new tab page less disruptive.
  • Mini-sessions: If you remove 'tabpages' from 'sessionoptions', :mksession will only pay attention to the current tab page. This makes it easy to use tab pages as a lightweight project-organization tool -- just open a set of files in whatever window layout you like, then run `:mksession some-random-project.vim` to save the current tab page as a session. To work on that set of files again, open a new tab page and :source the appropriate session file.
This one would probably be best as a section in a "using sessions" tip, if we have one.
Advertisement