Abrir un archivo en una pestaña en vim en modo de solo lectura


Soy consciente de abrir archivos en modo readonly desde shell usando vim -R, pero ¿cómo abrir un archivo desde dentro de vim en una pestaña separada (:tabe <filename>) en modo readonly?

Gracias por su tiempo.

Author: Andy Lester, 2010-10-28

7 answers

Para abrir un archivo en modo de solo lectura en una nueva pestaña, use

tab sview /path/to/file

Para abrir el archivo en el mismo panel, (sin usar una nueva ventana o pestaña), use

view /path/to/file

Tenga en cuenta que tab view /path/to/file no abre una nueva pestaña.

 69
Author: ZyX,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-01-11 16:37:11

Puede abrir un archivo en modo readonly desde dentro de vim:

:view /path/to/file

O desde la línea de comandos:

$ vim -M /path/to/file
 30
Author: user2015258,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-11-25 11:27:22

vim -M filename abre el archivo en modo de solo lectura.

 18
Author: janwen,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-10-19 12:39:45

Simplemente abra su archivo usando :tabe <filename>, luego ingrese :view. Cambiará automáticamente al modo de solo lectura.

 13
Author: Jeyamaran,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-01-09 23:04:23

Intenta :tabedit +set\ noma|set\ ro FILE; esto abrirá FILE en una nueva pestaña con modifiable desactivado y readonly activado, evitando que modifiques o escribas el archivo. Si solo quieres readonly, omite el conjunto noma. Podría ser conveniente reasignar esto a otro comando.

 4
Author: Wyatt Anderson,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2010-10-28 14:28:36

Algo que funciona para mí:

:vnew path/to/file

Y una vez abierto el archivo, dé el comando view:

:view
 1
Author: Vivek,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-09-29 09:54:12
vim -R /path/to/file
vim -m /path/to/file

Modo de solo lectura. Se permite modificar el texto pero no se puede escribir (no se puede guardar).

vim -M /path/to/file

Incluso la modificación en el texto no está permitida.

 1
Author: GyuHyeon Choi,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-06-07 03:20:11