Tuesday, February 2, 2010

Re: autocmd fails for a filetype

* Tim Johnson <tim@johnsons-web.com> [100202 17:27]:
> I'm using vim normal version, gvim huge version both of
> version number 7.2 on slackware 13.0.
>
> I have the following lines in my .vimrc
> autocmd BufNewFile,BufRead *.lsp setf newlisp
> autocmd BufNewFile,BufRead *.lsp so ~/.vim/syntax/newlisp.vim
> autocmd BufRead,BufNewFile *.lsp setlocal shiftwidth=2 tabstop=2
> autocmd BufRead,BufNewFile *.lsp setlocal iskeyword+=:
>
> If a open a file with an extension of .lsp and from ex
> :set shiftwidth
> I see that indeed, shiftwidth is set to 2
> but
> if I invoke
> :echo &ft
> I see that the filetype is *lisp* not newlisp. And it does not
> appear that ~/.vim/syntax/newlisp.vim has been sourced.
> What am I doing wrong here?
*This time* I found the solution myself. <g>
By loading vim as in `vim -V -D' I can step through
the order in which vim loads files. I could see that
that /usr/local/share/vim/filetype.vim was being loaded before
the abovementioned au commands. (Or in the case of gvim,
/usr/share/vim/filetype.vim)
The load is triggered from .vimrc (I think) by the following
code:
"" --------------------------------------------------------
if has("autocmd")
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
endif " has("autocmd")
"" --------------------------------------------------------
so I moved the following:
> autocmd BufNewFile,BufRead *.lsp setf newlisp
> autocmd BufNewFile,BufRead *.lsp so ~/.vim/syntax/newlisp.vim
to a line prior to
if has("autocmd")
autocmd BufReadPost * .......

cheers
--
Tim
tim@johnsons-web.com
http://www.akwebsoft.com

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

No comments: