Monday, July 30, 2012

Re: Filetype detection on vim

On 31/07/12 11:49 AM, ping wrote:
> On 7/30/2012 9:28 PM, Gary Johnson wrote:
>> On 2012-07-30, ping wrote:
>>>>>
>>>>>
>>>>> What I recommend is to add a new filetype.vim in one of the following
>>>>>
>>>>> places (shown as they would appear in Vim):
>>>>>
>>>>>
>>>>>
>>>>> - Single-user on Windows
>>>>>
>>>>> $HOME/vimfiles/filetype.vim
>>>>>
>>>>
>>>> I actually prefer creating a file per filetype in
>>>> $HOME/vimfiles/ftdetect, as detailed at the beginning of
>>>> :help new-filetype
>>>>
>>>
>>> vim help doesn't mention anything about vimfiles directory...
>>
>
>
> not sure if this is what it was originally posted, but I did the following test,
> still confusing..
>
> created file .vim/ftdetect/log.vim, here is the content:
>
> 1 au BufRead *.log,*.txt call s:FTmy()
> 2 echo "we are in log.vim"
> 3
> 4 function! s:FTmy()
> 5 echo "we are under Ftmy"
> 6 endfunction
>
> while open a temp.log file, I see "we are in log.vim", but not see "we are under
> FTmy"...
>
> am I missing anything here?

If temp.log is not an existing file, but a new file, it could be because
you omitted BufNewFile from the autocommand. Try

au BufRead,BufNewFile *.log,*.txt call s:FTmy()

Ben.



--
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

No comments: