Open a file in a tab in vim in readonly mode

五迷三道 提交于 2019-12-02 17:24:02
ZyX

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.

user2015258

You can open a file in readonly mode from inside vim:

:view /path/to/file

or from command line:

$ vim -M /path/to/file
janwen

vim -M filename opens the file in readonly mode.

Jeyamaran

Just open your file by using :tabe <filename>, then enter :view. It will automatically switch to read-only mode.

Try :tabedit +set\ noma|set\ ro FILE; this will open FILE in a new tab with modifiable off and readonly on, preventing you from modifying or writing the file. If you just want readonly, omit the noma set. Might be convenient to remap this to another command.

vim -R /path/to/file
vim -m /path/to/file

Read-only mode. Modification in text is allowed but you cannot write (no saving).

vim -M /path/to/file

Even modification in text is not allowed.

Something that works for me:

:vnew path/to/file

and once the file is opened, give the view command:

:view
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!