I inferred too much from your comment in your earlier post about
opening a new file in /usr/share/vim/vim80/doc. Newcomers to Vim
often do not understand the problems with modifying or adding files
under $VIMRUNTIME (in your case, /user/share/vim/vim80) and I wanted
to help you avoid those problems.
> In my ~/.vimrc, i don't see where i source filetype.vim. Should i have
> a lign so filetype.vim?
No, you don't need a line in your ~/.vimrc to source filetype.vim.
Vim automatically sources filetype.vim when it executes the ":syntax
on" or ":filetype on" commands. Those commands are usually in the
system vimrc provided by your Linux distribution's vim package.
> /usr/share/vim/vim80/ has a subdirectory called syntax, but it contains
> many .vim files with many syntaxes. I don't understand why file in doc
> directory uses help.vim.
The files in /usr/share/vim/vim80/doc use help.vim because of the
line I quoted earlier from $VIMRUNTIME/filetype.vim:
au BufNewFile,BufRead $VIMRUNTIME/doc/*.txt setf help
That is an autocommand that sets the 'filetype' to help for every
file opened whose path name matches the pattern
$VIMRUNTIME/doc/*.txt
Vim also uses modelines in help files to set the filetype to "help".
Look at the last line of any file in $VIMRUNTIME/doc. It will look
like this example from $VIMRUNTIME/doc/workshop.txt:
vim:tw=78:ts=8:noet:ft=help:norl:
If you put that line as the last line of your files, their filetype
will be set to "help" when they are opened.
> As for me, in my directory, say ~/mathieu, i want that every .txt file
> that i create uses help.vim syntax.
The easiest way to do that is to put that modeline at the bottom of
every .txt file in that directory. Another way to do that is to
create an autocommand to set the filetype to "help" for any file
whose path name matches the pattern
~/mathieu/*.txt
If you want to use that second method, read
:help new-filetype
I know that you're not adding a new filetype, you're adding a new
pattern to detect an existing filetype, but in this case, the
solution is the same.
> I copied help.vim file in ~/mathieu and in ~/mathieu/syntax. I tried
> :syntax on
> But it does not work.
>
> The only solution for me is to do :so help.vim
> But when i close my .txt file and open it again, i have to do :so
> help.vim again.
>
> I am sorry, i am quite a beginner in vim, but i really don't understand
> your explanation.
I hope the explanation above is better.
Regards,
Gary