Possible bug: Newly-edited buffer gets its 'modifiable' setting from buffer in which :edit or :split command is executed

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Possible bug: Newly-edited buffer gets its 'modifiable' setting from buffer in which :edit or :split command is executed

Stahlman Family
Steps to reproduce...

:e file1
:set noma
:sp file2

At this point, `set ma?' indicates that file2's buffer is
'nomodifiable'. This seems strange to me, given that the 'modifiable'
option is "local to buffer", and file1 and file2 obviously do not share
a buffer. The result is the same when :e is used instead of :sp.

Is this a bug?

Thanks,
Brett Stahlman

--
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 | Threaded
Open this post in threaded view
|

Re: Possible bug: Newly-edited buffer gets its 'modifiable' setting from buffer in which :edit or :split command is executed

Benjamin Fritz


On Jun 6, 10:19 pm, Stahlman Family <[hidden email]> wrote:

> Steps to reproduce...
>
> :e file1
> :set noma
> :sp file2
>
> At this point, `set ma?' indicates that file2's buffer is
> 'nomodifiable'. This seems strange to me, given that the 'modifiable'
> option is "local to buffer", and file1 and file2 obviously do not share
> a buffer. The result is the same when :e is used instead of :sp.
>
> Is this a bug?
>

I'm not sure if it's documented anywhere, but I understand that even
for the "local to ..." options, Vim has a global counterpart. Each
buffer can have its own copy of a buffer-local option, but the global
copy is the default for new buffers.

The 'binary' option, for example, acts in the same way.

If you want to avoid this, use :setlocal instead of :set.

--
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 | Threaded
Open this post in threaded view
|

Re: Possible bug: Newly-edited buffer gets its 'modifiable' setting from buffer in which :edit or :split command is executed

Stahlman Family


Ben Fritz wrote:

>
> On Jun 6, 10:19 pm, Stahlman Family <[hidden email]> wrote:
>> Steps to reproduce...
>>
>> :e file1
>> :set noma
>> :sp file2
>>
>> At this point, `set ma?' indicates that file2's buffer is
>> 'nomodifiable'. This seems strange to me, given that the 'modifiable'
>> option is "local to buffer", and file1 and file2 obviously do not share
>> a buffer. The result is the same when :e is used instead of :sp.
>>
>> Is this a bug?
>>
>
> I'm not sure if it's documented anywhere, but I understand that even
> for the "local to ..." options, Vim has a global counterpart. Each
> buffer can have its own copy of a buffer-local option, but the global
> copy is the default for new buffers.

Ben,
Sorry. I see now that it's documented...

"""
When editing a new buffer, its local option values must be initialized.
  Since the local options of the current buffer might be specifically
for that buffer, these are not used.  Instead, for each buffer-local
option there also is a global value, which is used for new buffers.
With ":set" both the local and global value is changed.  With "setlocal"
only the local value is changed, thus this value is not used when
editing a new buffer.
"""

I should have dug a bit deeper...

Thanks,
Brett Stahlman

>
> The 'binary' option, for example, acts in the same way.
>
> If you want to avoid this, use :setlocal instead of :set.
>

--
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 | Threaded
Open this post in threaded view
|

Re: Possible bug: Newly-edited buffer gets its 'modifiable' setting from buffer in which :edit or :split command is executed

Bram Moolenaar
In reply to this post by Stahlman Family

Brett Stahlman wrote:

> Steps to reproduce...
>
> :e file1
> :set noma
> :sp file2
>
> At this point, `set ma?' indicates that file2's buffer is
> 'nomodifiable'. This seems strange to me, given that the 'modifiable'
> option is "local to buffer", and file1 and file2 obviously do not share
> a buffer. The result is the same when :e is used instead of :sp.
>
> Is this a bug?

No, this is intended.  If you use "set noma" then this value becomes the
default for new buffers.  If you only want to set the option in the
current buffer you need to use ":setlocal noma".

I know it may feel a bit strange, but it's required to be compatible
with Vi and older versions of Vim.

--
hundred-and-one symptoms of being an internet addict:
171. You invent another person and chat with yourself in empty chat rooms.

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--
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 | Threaded
Open this post in threaded view
|

Re: Possible bug: Newly-edited buffer gets its 'modifiable' setting from buffer in which :edit or :split command is executed

mMontu
On Monday, June 7, 2010 6:32:17 PM UTC-3, Bram Moolenaar wrote:
> No, this is intended.  If you use "set noma" then this value becomes the
> default for new buffers.  If you only want to set the option in the
> current buffer you need to use ":setlocal noma".
>
> I know it may feel a bit strange, but it's required to be compatible
> with Vi and older versions of Vim.

I got the same misunderstanding from the "local to buffer", and this seems that more did the same: http://stackoverflow.com/questions/18782020/

Maybe this could be included on `:help 'modifiable'`.

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.