> * 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+=:
>
> *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)
See :help new-filetype, but the problem is basically just caused by
you using ":setf newlisp" instead of ":set filetype=newlisp". What
actually going wrong for you is that your check was coming after the
default checks, by which point *.lsp had already been recognized by
one of the default checks, which did ":setf lisp". Then, your autocmd
fired, and ":setf newlisp" didn't do anything because 'ft' had already
been set.
> 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 * .......
You hacked around the problem by forcing your autocmds to be defined
before the filetype autocmds, but not in a reliable way - that will
break if your distro turns on syntax highlighting in the systemwide
vimrc, for example. The better solution would be to use ":set
filetype=newlisp" in the autocmd instead, or to use one of the file
based approaches documented at :help new-filetype . If you use :set
filetype=newlisp, the order won't matter. Either your filetype choice
will get set first, and the normal checks will refuse to override it,
or the normal checks will set it first, and then your autocmd will
override it.
~Matt
--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
No comments:
Post a Comment