Is there a way to tell emacs/vi/vim (from the command line) that I want to view the file in
I know how to open a file as read only if emacs/vi/vim is already running.
There's no startup option to force read only.
allows writing with
Prevents the user from making any changes to the file in the buffer. But the user could make the buffer modifiable with
You could use
to prevent the user from turning off the "nomodifiable", and allow the user to quit by pressing
You could also open the file with the less command:
To view the file in a vim-like environment but without the ability to change the file.
For emacs you can also use the view-mode.
or alternative inside a terminal:
Or you can use my wrapper script
Small follow-up to the accepted answer: You can alias this in your shell to reduce it to a single command. For example in bash you can put the following in your .bashrc:
(different shells will have different formats for doing this, but you get the idea)
I would have added this as a comment in reply to the accepted answer, but it didn't seem possible to have a multi-line "code" block in a comment, and (in bash anyway) the above code really does need to be on 3 separate lines.
sending a file to std out, may be acceptable given the size of the file