Vim may not properly work with ":set cpo+=W"

15 views
Skip to first unread message

Jason Franklin

unread,
Aug 3, 2019, 11:07:35 AM8/3/19
to vim_dev
Perhaps I'm not understanding how this option works.

When I create a file on my desktop with write permission and open
it with "vim -R file.txt", I can run ":set cpo+=W" and then still
write the file with :w! or by confirming a prompt (with :set confirm).

Is this the intended behavior?

I would like to stop myself from *ever* overwriting a file that has
the 'readonly' option set (unless I manually disable 'ro').

Thanks,
Jason Franklin

Bram Moolenaar

unread,
Aug 3, 2019, 4:29:37 PM8/3/19
to vim...@googlegroups.com, Jason Franklin

Jason Franklin wrote:

> Perhaps I'm not understanding how this option works.
>
> When I create a file on my desktop with write permission and open
> it with "vim -R file.txt", I can run ":set cpo+=W" and then still
> write the file with :w! or by confirming a prompt (with :set confirm).
>
> Is this the intended behavior?

What matters is if the file is read-only, not whether 'readonly' is set.

> I would like to stop myself from *ever* overwriting a file that has
> the 'readonly' option set (unless I manually disable 'ro').

There is the 'write' option, but it's global. Perhaps we should make it
global-local?

--
Shift happens.
-- Doppler

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages