Tuesday, May 14, 2019

Re: help.vim's syntax

On 2019-05-14, Mathieu Roux wrote:
> Hi everybody,
>
> I have understood that for vim's help, the syntax file used is help.vim
> (in the directory /usr/share/vim/vim80/syntax).
>
> I can use it with:
> :so help.vim
> (if it is in the same directory of the file i open)
>
> But i still don't understand why, when i open one file in
> /usr/share/vim/vim80/doc
> EVEN A NEW FILE
> it automatically uses the syntax of help.vim, whereas i do nothing...
> Maybe someone can explain me.

This is explained in

:help syntax

In short, when you enable syntax highlighting by executing

:syntax enable

in your vimrc, you source $VIMRUNTIME/filetype.vim, which contains:

" Vim help file
au BufNewFile,BufRead $VIMRUNTIME/doc/*.txt setf help

Whenever you open a file matching that pattern, Vim sets the
'filetype' to "help" and (with the aid of a few other scripts)
sources $VIMRUNTIME/syntax/help.vim.


You wrote above that you opened a new file in
/usr/share/vim/vim80/doc. Do not create new syntax files in that
directory. Do not create new files or modify any files anywhere
under /usr/share/vim/vim80. Those directories are for files
included with the Vim package. Any files in those directories may
be overwritten by an update to the Vim package and will not be
accessed when you upgrade to a version later than 8.0.

Instead, put any files you create for you own use under ~/.vim or
any that you want to share with other users under
/usr/share/vim/vimfiles. Then they will be safe from any changes to
your distribution's Vim package and will continue to be used even if
you build Vim yourself.

Regards,
Gary

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20190514201702.GA14560%40phoenix.
For more options, visit https://groups.google.com/d/optout.

No comments: