10

How do I open a file to view in a new tab? Specifically, I want the read-only equivalent of :tabe[dit] <filename>. I have tried

:tab :view <filename>

but that does not create a new tab as the documentation would suggest.

kenorb
  • 18,433
  • 18
  • 72
  • 134
adurity
  • 203
  • 2
  • 5

1 Answers1

8

:tab <cmd> opens a tab where a <cmd> would have opened a window. :view doesn't open a window, so :tab view doesn't open a tab :-) See :help :tab.

However, we also have the :sview command, which does:

Same as ":split", but set 'readonly' option for this buffer.

This does open a window. So :tab sview file opens a tab.

:sview is short for "split view". You can abbreviate to to :sv, and you can also leave out the second :.


Postscript:
Your question suggests you're not very familiar with Vi/Vim terminology. Many people are confused about this, so don't worry :-) :help window is a good read for an introduction. It has a useful summary at the start:

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.

Martin Tournoij
  • 62,054
  • 25
  • 192
  • 271
  • 1
    Thanks. Just what I was looking for. And thanks for the primer on vi/Vim terminology. One correction: while the command is called "splitview" the :splitview command does not exist. It's just :sview or :sv. – adurity Feb 23 '15 at 23:57
  • @adurity Oops, thanks. That was in the help file, but I misread >_< – Martin Tournoij Feb 24 '15 at 00:01