Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open a file in a tab in vim in readonly mode

Tags:

vim

tabs

readonly

I'm aware of opening files in readonly mode from shell using vim -R, but how to open a file from inside vim in a separate tab (:tabe <filename>) in readonly mode?

Thanks for your time.

like image 298
Srikanth Avatar asked Oct 28 '10 14:10

Srikanth


People also ask

How do I override a readonly file in vim?

Just use vi's exclamation mark suffix to the write command (:w!) to force overwriting your own READONLY file.

Which command opens an existing file in read only mode?

There are many modes for opening a file: r - open a file in read mode. w - opens or create a text file in write mode.

Which option is used by vi editor to open a file in read mode only?

Starting the vi Editor. vi filename: Creates a new file if it already not exist, otherwise opens existing file. vi -R filename : Opens an existing file in read only mode. view filename : Opens an existing file in read only mode.


1 Answers

To open a file in read only mode in a new tab, use

tab sview /path/to/file 

To open the file in the same pane, (without using a new window or tab), use

view /path/to/file 

Note that tab view /path/to/file does not open a new tab.

like image 111
ZyX Avatar answered Sep 23 '22 03:09

ZyX