strange behavior: ":w" only writes new buffers to disk, not open them.

40 views
Skip to first unread message

leo

unread,
Aug 20, 2013, 9:16:43 PM8/20/13
to vim...@googlegroups.com

Hello all,

I have changed my .vimrc quite a bit recently. I do not know exactly when, but when a create new buffer, for instance ":w test.txt", vim only writes/creates the file test, but it no longer opens it by default. Is there any option that controls that? I'm using macvim

Thanks in advance

Tim Chase

unread,
Aug 20, 2013, 9:34:04 PM8/20/13
to vim...@googlegroups.com, barbosa....@gmail.com
On 2013-08-20 18:16, leo wrote:
> when a create new buffer, for instance ":w test.txt", vim
> only writes/creates the file test, but it no longer opens
> it by default. Is there any option that controls that?

I'm not quite sure I understand what you mean by "no longer opens it
by default". Based on my reading, there are two possible meanings
that occur to me:

1) when creating a new buffer (":new") and then writing it (":w
test.txt"), it writes the file but doesn't change the buffer-name to
associate it with the file on disk. If this is the case, this is
clearly a regression. I'd test to see if you can duplicate it with
after you've started vim with "vim -u NONE" to eliminate any
possibility of vimrc files interfering.

2) when creating a new buffer against an existing file (":e
existing.txt") and then writing a new file (":w test.txt"), it
doesn't change the file-name (i.e., subsequent writes write to
"existing.txt"), this is the expected behavior. To write to a new
file and change to that one instead, you want to use ":saveas
test.txt" instead of ":w test.txt"


It would help to know:
- which one of the above you're talking about,
- which version of Vim you're running ("7.2.314")
- any plugins or particularly germane settings you might have in your
vimrc

-tim



Leonardo Barbosa

unread,
Aug 20, 2013, 10:02:22 PM8/20/13
to Tim Chase, vim...@googlegroups.com
Thanks Tim,

a) I'm talking about the first one.
b)
:version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jul 27 2011 19:46:24)
MacOS X (unix) version
c) "vim -u NONE" makes vim works as expected.

what do you think?

Leo

Tim Chase

unread,
Aug 20, 2013, 10:21:39 PM8/20/13
to vim...@googlegroups.com, barbosa....@gmail.com
On 2013-08-20 23:02, Leonardo Barbosa wrote:
> c) "vim -u NONE" makes vim works as expected.

then I'd start binary-searching your vimrc by putting

finish

halfway through. If it still works, move it to 75% of the way
through; otherwise, move it to 25% of the way through. By cutting
your vimrc in half each time, you should be able to determine the
problematic line.

Alternatively, you could try including posting your vimrc here to get
other eyes on what might be causing the problem.

-tim


Leonardo Barbosa

unread,
Aug 21, 2013, 5:26:18 AM8/21/13
to Tim Chase, vim...@googlegroups.com
Thanks again! The problems seems to be the combination of these two lines
let &showbreak = '↳ ' " if you can't see this character, it's a return arrow
set cpo=n

Indeed, i have set those, recently.

Leo

Christian Brabandt

unread,
Aug 21, 2013, 6:06:50 AM8/21/13
to vim...@googlegroups.com
On Wed, August 21, 2013 11:26, Leonardo Barbosa wrote:
> set cpo=n

This is you error. You probably want to add the 'n' flag
to the 'cpo' settings and not have 'cpo' only contain the 'n'.

The difference is, in the former, the default flag 'F' will still
be available, which is responsible for setting the filename of
the current buffer to the one supplied by the :w command.
If it isn't there (e.g. by setting cpo=n), Vim won't set the buffername
and this is what you are currently experiencing.

See also the help:
:h cpo-F

regards,
Christian

Tim Chase

unread,
Aug 21, 2013, 10:15:16 AM8/21/13
to vim...@googlegroups.com, cbl...@256bit.org
Christian nailed the issue (including digging up which option, 'F',
was the culprit that got wiped out), however he omitted the most
important detail: how to fix it. If you got caught by this, it might
have been helpful to include the remedy, to change

set cpo=n

to

set cpo+=n

as mentioned at

:help :set+=

-tim



Ben Fritz

unread,
Aug 21, 2013, 10:20:57 AM8/21/13
to vim...@googlegroups.com
On Wednesday, August 21, 2013 5:06:50 AM UTC-5, Christian Brabandt wrote:
> On Wed, August 21, 2013 11:26, Leonardo Barbosa wrote:
>
> > set cpo=n
>
>
>
> This is you error. You probably want to add the 'n' flag
>
> to the 'cpo' settings and not have 'cpo' only contain the 'n'.
>
>

In other words, you probably want this:

set cpo+=n

NOT this:

set cpo=n

Leonardo Barbosa

unread,
Aug 21, 2013, 10:41:31 AM8/21/13
to vim...@googlegroups.com
Cool. Fixed! Thank you all
> --
> --
> 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 a topic in the Google Groups "vim_use" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/vim_use/YPcNy12ubaU/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to vim_use+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages