0

I'm making tentative steps into using tabs in Vim. It seems a bit ridiculous, I've been using tabs in everything for the last 18 years:

  • Visual Studio
  • Every browser since Opera came up with them
  • Notepad++
  • Sublime Text
  • Bash terminals

As you can see it's mostly Windows, but I really want to switch to proper free and open tools for my dev work, so I want to switch off Sublime Text into Vim.

I've also been a fairly basic user of Vim for 18 years. I only just realised that Vim does have tabs in it! Don't I feel clever...

So ok, great so Vim has tabs, but really they're not tabs, but they are, but they're not.

The Vim wiki on tab 'pages' has a mildly helpful start:

In Vim, each file is loaded into a buffer, which can be displayed in any number of windows, in any number of tabs.

I can just about get that, they're really flexible, which I can imagine is great. You could split a single file across tabs I'd imagine, I've never felt the need to do that, but I'm sure there's a use case for it.

But then the wiki falls off the edge of my knowledge whilst at the same time trying to claim they're making it easier for me:

The easiest way to think about tab pages in Vim is to consider them to be viewports, layouts, or workspaces.

My question:

Ok... so as it's so easy could someone explain to me what the following are in terms of Vim:

  • viewport
  • layout
  • workspace

P.S. I've been found a helpful answer on this SO question on Using Vim's tabs like buffers:

A buffer is the in-memory text of a file.
A window is a viewport on a buffer.
A tab page is a collection of windows.

But again that doesn't explain what a viewport is, or a layout or a workspace. None of which I've heard of in terms of an editor before. (Well actually Sublime Text has workspaces but I'm sure they mean something different there)

Yes, I could keep googling down the rabbit hole, but I didn't expect the rabbit hole to be this deep.

  • Clearly related answer: vi.stackexchange.com/questions/9016/… – icc97 Mar 30 '17 at 11:15
  • Other clearly related answer: stackoverflow.com/questions/26708822/… – icc97 Mar 30 '17 at 11:19
  • Useful article explaining viewports: linux.com/learn/vim-tips-using-viewports – icc97 Mar 30 '17 at 12:52
  • 1
    I think you might be overthinking this a little. In Vim, a tab is simply a group of Vim's windows. "Viewport", "layout", and "workspace" are not Vim terminology: they're just three other words you might have seen to describe the same concept outside of Vim, so if you're already familiar with these terms, the person that wrote that part of the wiki thought that they might help you to understand what a "tab" is in Vim. – Rich Mar 30 '17 at 13:27
  • @Rich thanks for your comment. That's too what I'd assume. But all of those terms mean nothing to me. The only place I hear of viewport is people discussing Vim. It's also directly in Vim's :help window: "A window is a viewport onto a buffer". The more I read about this it slowly makes sense. Of course the dictionary definition of viewport makes sense "a framed area on a display screen for viewing information", but I've never heard this referred to in other editors. – icc97 Mar 30 '17 at 14:39
1

As @Rich comments, I'm possibly over thinking this. But I've never heard of viewport or layout with regards to a text editor and I've only heard of 'workspace' referred to with regards to the list of files you have open for Sublime Text.

However in responding to his question, actual computer science dictionary definitions of the words kind of make sense:

Workspace (computing):

"A memory storage facility for temporary use."

-- ref

Viewport (computing):

A framed area on a display screen for viewing information.

-- ref

Both of those make sense.

Layout

Layout doesn't seem to make any sense as far as I can tell. You have page layout for web pages but tabs don't really position things on a screen, they just allow you to subdivide what your working on

There's the Wikipedia definition:

In computing, layout is the process of calculating the position of objects in space subject to various constraints. This functionality can be part of an application or packaged as a reusable component or library.


I certainly understand now that viewport is equivalent to window.

The Vim Tips using Viewports article I found very helpful, in the simple sense that it explains just running :help <command> e.g. :help window will open that up in a 'window' / 'viewport'

However in my head now, I think it makes sense that when coming from another editor I should just not bother with tab pages and stick to buffers. Open a new buffer as I would open a new tab. Then you can search the open buffers that you have and switch between them. Somewhat similar to running Ctrl +P and searching for a new file with Sublime Text.

  • 1
    Re: Layout, each Vim tab is a "layout" of Vim windows. Each Vim window is positioned within the tab, on the screen. Otherwise, I think this is a pretty good answer to your own question! – Rich Mar 31 '17 at 9:20
  • @Rich ah, yes! Good point – icc97 Mar 31 '17 at 9:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.