On Jan 7, 3:57 pm, Taylor Hedberg <[email protected]> wrote:
> It's important to recognize that Vim makes a distinction between
> readonly and nomodifiable options. Setting readonly will prevent you
> from saving the buffer unless you type ":w!" (with the exclamation
> point). Setting nomodifiable, on the other hand, will prevent you from
> even entering insert mode or modifying the buffer itself in any way.
>
> You can open a file with readonly set by using the :view command, but it
> will still be modifiable unless you explicitly :set nomodifiable. As far
> as opening a file with nomodifiable already set, I'm not aware of any
> command that does that (though that doesn't mean there isn't one).

There is also :sview to split a window in readonly mode.

You can force nomodifiable whenever a buffer opens read-only with this
autocmd from my .vimrc:

    " set readonly files to also be non-modifiable by default, and
others to be
    " modifiable by default
    autocmd BufRead,BufWinEnter * if &ft!='qf' | let &l:modifiable =
(&readonly ? 0 : 1) | endif

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to