Tomáš Kazmar schrieb:
Hi,

  i am knew to this list so i apologise if this kind of suggestion is not 
welcome.

Is it possible to have files with .txx extension included in the list of cpp 
files in filetype.vim
like this:

" C++
if has("fname_case")
  au BufNewFile,BufRead 
*.cxx,*.c++,*.C,*.H,*.hh,*.hxx,*.hpp,*.moc,*.tcc,*.inl,*.txx setf cpp
else
  au BufNewFile,BufRead *.cxx,*.c++,*.hh,*.hxx,*.hpp,*.moc,*.tcc,*.inl,*.txx 
setf cpp
endif

The problem is that a filetype of txx file (as any other cpp file with an 
extension not included
in the list) is guessed to be 'conf', due to the following and the fact there 
can be some
preprocessor lines in a cpp file:

" Generic configuration file (check this last, it's just guessing!)
au BufNewFile,BufRead,StdinReadPost *
        \ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
        \    && (getline(1) =~ '^#' || getline(2) =~ '^#' || getline(3) =~ '^#'
        \       || getline(4) =~ '^#' || getline(5) =~ '^#') |
        \   setf conf |
        \ endif

Or not set up at all if there are at least 5 lines of comments at the beginning 
of file.

Is it possible to include it? txx files are used in libraries for cpp templated 
classes.
(e.g. http://www.itk.org/,http://www.vtk.org/, http://vxl.sourceforge.net)


Tomas

Users can define there own filetype.vim to detect additional filetypes.
Other places in the runtimepath are suited as well.

~/.vim/filetype.vim
-----------------------------------------------------
" my filetype file
" :help new-filetype
if exists("did_load_filetypes")
 finish
endif

" Line continuation is used here, remove 'C' from 'cpoptions'
let s:cpo_save = &cpo
set cpo&vim

augroup filetypedetect
 " libraries for cpp templated classes
 au! BufRead,BufNewFile *.txx           setf cpp
augroup END

" Restore 'cpoptions'
let &cpo = s:cpo_save
unlet s:cpo_save
-----------------------------------------------------

--
Regards,
Andy

Reply via email to