On 26/12/11 08:53, Thilo Six wrote:
Tony Mechelynck wrote the following on 26.12.2011 04:47

Hello

Thanks Thilo.

I found the Generic configuration code in my C:\Program Files (x86)\Vim
\vim73\filetype.vim
Where in the file should the local configuration code (below) be
placed?

" txt
    autocmd BufNewFile,BufRead
        \ *.txt,
        \*README*
        \ setl ft=text

wolfv

Sorry i am not familar with the windows version of vim. So you should follow
Tonys hint. But i want to share cool little feature i just figured:

,----[  ft=text  ]---------------------------

   " txt
   autocmd BufNewFile,BufRead
       \ *.txt,
       \\c*README*
       \ setl ft=text
`---------------------------------------------

The nice thing here is the additional '\c' which means 'ignore case'. At least i
didn't know until today that this can be used there, too. Nice.


On Windows, it could either be part of ~/vimfiles/filetype.vim, after

if exists("did_load_filetypes")
    finish
endif

Personly i would leave this out as i sometimes deliberately overwrite defaults

So what? $VIMRUNTIME/filetype.vim sets its filetypes by :setfiletype, which does nothing if the filetype is already set. So you can override them by setting the filetype in ~/vimfiles/filetype.vim (for Windows) or ~/.vim/filetype.vim (for Unix) which is sourced immediately before $VIMRUNTIME/filetype.vim. One possible reason not to use this (but to use ftdetect/foobar.vim or after/filetype/vim instead) would be if sometime you wanted to be sure _not_ to override defaults. You would then use ":setfiletype foobar" (not ":set filetype=foobar") in ftdetect/foobar.vim.

from '$VIMRUNTYME/filetype.vim'. I instead use:

,----[  ~/.vim/ftdetect/filetype.vim  ]-------

" only spend time on this once
   if exists("b:did_load_filetypes_user")
     finish
   endif
   let b:did_load_filetypes_user = 1
`---------------------------------------------

Oh and yes you can have '~/.vim/ftdetect/text.vim', '~/.vim/ftdetect/foo.vim'
and '~/.vim/ftdetect/bar.vim' or just throw everything in
'~/.vim/ftdetect/filetype.vim' as i do. As long as the file ends with '.vim' it
should work.
Again i do not know where this directory is on windows, most probably somewhere
below '%appdata%'. 'set runtimepath?' should help here. Use the first directory
as starting point.

Within Vim it is seen as below $HOME/vimfiles/, as follows (for Windows):

        :e $HOME
        :!mkdir %/vimfiles
        :e %/vimfiles
        :!mkdir %/ftdetect
        :e %/ftdetect/text.vim
or
        :e $HOME
        :!mkdir %/vimfiles
        :e %/vimfiles/filetype.vim

You can omit the each !mkdir commands if the corresponding directory already exists.

On Linux it's simpler because GNU mkdir has a -p switch:

        :!mkdir -pv ~/.vim/ftdetect
        :e ~/.vim/ftdetect/text.vim
or
        :!mkdir -pv ~/.vim
        :e ~/.vim/filetype.vim

I could have used the internal mkdir() function, except that it isn't guaranteed to exist on all platforms.

About the external command name: Unix has cd, mkdir, rmdir. Dos/Windows have them too, and also aliases chdir, md, rd, so their users often prefer cd, md, rd. I make a point of using mkdir and rmdir because they are more portable.


and possibly together with other user-defined filetype detection
autocommands (BTW do not set that did_load_filetypes variable, it is set
by $VIMRUNTYME/filetype.vim), or else it could be all of
~/vimfiles/ftdetect/text.vim (with paths shown as they could be used in
Vim but not in other Windows programs). Or you could replace ~/vimfiles/
by $VIM/vimfiles/ in either of these paths if you wanted these
customizations to apply to all users (all login names) on your computer.

See
        :help new-filetype

See also
        :help 'runtimepath'

about the different default paths on Windows ("PC") vs. Unix/Linux/OSX
("Unix").


Best regards,
Tony.
--
"If a team is in a positive frame of mind, it will have a good
attitude.  If it has a good attitude, it will make a commitment to
playing the game right.  If it plays the game right, it will win --
unless, of course, it doesn't have enough talent to win, and no manager
can make goose-liver pâté out of goose feathers, so why worry?"
                -- Sparky Anderson

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

Reply via email to