SHANKAR R-R66203 wrote:

 How do I open a new file in a new tab, but in the read only mode.

 :tabedit -R file_name

Does not seem to work.
Why would you think it would? I see no mention of a "-R" modifier for tabedit. Here's the
help for tabedit:

:tabe[dit]                              *:tabe* *:tabedit* *:tabnew*
:tabnew         Open a new tab page with an empty window, after the current
               tab page.

:tabe[dit] [++opt] [+cmd] {file}
:tabnew [++opt] [+cmd] {file}
               Open a new tab page and edit {file}, like with |:edit|.

No minus-anythings there. At least it'd seem more likely that a "+" something might work...

OK, so let's look around:

:he tab<tab>

to see a list of tab related help items/commands. The first command on that list is

 :tab

The help for that says:

Execute {cmd} and when it opens a new window open a new tab page instead. ..snip..

OK, so let's look around for something that will open a new window, but in read-only mode. Doing :he readonly<tab> gives us readonly, write-readonly, and noreadonly,
none of which seem to me to be likely to help.  So, let's try

:helpgrep readonly
:cope

Look over the list of matches in the quickfix window (which is what :cope opened) for windows.txt; because, after all, what you want is to open a readonly window.
Hmm, there's a line:

windows.txt|185 col 30| Same as ":split", but set 'readonly' option for this buffer.

which, when I hit the <cr> and go to it, mentions something about the sview command.

So, put the two together:   :tab sview SomeFile
and you get your new tab with readonly set, opened to SomeFile.

Regards,
Chip Campbell



Reply via email to