badd and syntax

1 view
Skip to first unread message

Michal Kurgan

unread,
Nov 19, 2008, 1:54:47 PM11/19/08
to vim_use
Hello!

I've found strange behaviour in vim.

When doing "autocmd VimEnter * nested badd ..." syntax highlight work as
expected, means i see colors. I can use "bnext" and see colors in all badd'ed
files.

However if i do "autocmd VimEnter * nested source ..." and inside the file i
use badd, then there are no colors in buffers unless i run "edit ..." (this
can be done in the sourced file). When using bnext i don't see colors
(i.e. "syntax" returns "No Syntax items defined for this buffer).

I guess that some issue with autocomd's. Is there something that i miss? How
can i correctly add buffer in the file sourced in "autocmd VimEnter".

--
Michal Kurgan


Andy Wokula

unread,
Nov 20, 2008, 12:16:17 PM11/20/08
to vim...@googlegroups.com
Michal Kurgan schrieb:

> Hello!
>
> I've found strange behaviour in vim.

maybe it's rather caused by your strange setup?

> When doing "autocmd VimEnter * nested badd ..." syntax highlight work as
> expected, means i see colors. I can use "bnext" and see colors in all badd'ed
> files.

didn't check the above, but expected to work

> However if i do "autocmd VimEnter * nested source ..." and inside the file i
> use badd, then there are no colors in buffers unless i run "edit ..." (this
> can be done in the sourced file). When using bnext i don't see colors
> (i.e. "syntax" returns "No Syntax items defined for this buffer).

works here, without problems:

gvim.exe -N -u e_vimrc -U NONE

" --- e_vimrc ---
au VimEnter * nested source addfiles.vim
syntax on

" --- addfiles.vim ---
badd start.bat
badd e_vimrc

> I guess that some issue with autocomd's. Is there something that i miss? How
> can i correctly add buffer in the file sourced in "autocmd VimEnter".

usually to have some files in the buffer list after startup, one
will use :args (much better than :edit-ing all the files).

--
Andy

Michal Kurgan

unread,
Nov 20, 2008, 2:34:53 PM11/20/08
to vim...@googlegroups.com
On Thu, 20 Nov 2008 18:16:17 +0100
Andy Wokula <anw...@yahoo.de> wrote:

>
> Michal Kurgan schrieb:
> > Hello!
> >
> > I've found strange behaviour in vim.
>
> maybe it's rather caused by your strange setup?
>
> > When doing "autocmd VimEnter * nested badd ..." syntax highlight work as
> > expected, means i see colors. I can use "bnext" and see colors in all
> > badd'ed files.
>
> didn't check the above, but expected to work
>

It turns that i have to experiment more to find what is the problem, see
below.

> > However if i do "autocmd VimEnter * nested source ..." and inside the
> > file i use badd, then there are no colors in buffers unless i run
> > "edit ..." (this can be done in the sourced file). When using bnext i
> > don't see colors (i.e. "syntax" returns "No Syntax items defined for this
> > buffer).
>
> works here, without problems:
>

> [ ... ]

I found that the culprit was bufdo command that i used in sourced file right
after series of badd calls... It's is even written that Syntax is disabled
there, thus it enumerates buffers and disables colors. What is strange,
colors are there when buffers are opened with "edit" before the bufdo.

In my case moving bufdo before badd calls or adding "edit's" solved problem.
Now, if *this* bufdo behaviour is normal...

--
Michal Kurgan


Reply all
Reply to author
Forward
0 new messages