Re: Changing windows in the filetype autocommand
- On Wed, 30 Apr 2003 at 11:51am, Benji Fisher wrote:
> Yegappan Lakshmanan wrote:As a work-around (if no proper solution is found), you could also see if
> > Hi all,
> > I am facing a problem in switching windows in a FileType
> > autocommand.
> > When a C file is loaded, I want to open a new window and position
> > the cursor back in the original window.
> > I tried using the following FileType autocmd:
> > autocmd FileType c nested new | wincmd p
> > With this autocmd, the filetype for the C file is detected
> > as "conf" instead of as "C". Is this a bug?
> > The above autocmd is an simplified form of the problem I
> > am facing in using the taglist plugin.
> IIRC, there are problems with doing this that are not very well
> documented. (Something like this came up on the list a few months ago and I
> tried to find a solution then.) Basically, autocommands do not expect you to be
> switching buffers while they are executing. Have you tried an alternative to
> "wincmd p", like using winnr() ?
> HTH --Benji Fisher
disabling some autocommands (such as BufNew and BufAdd) before doing a
:new could help. Something like this:
autocmd FileType c nested :let _eventignore = &eventignore | set eventignore+=BufNew,BufAdd | new | wincmd p | let &eventignore = _eventignore
You could try disabling other events too, such as WinEnter/WinLeave and