This section below is obtained from gvim session by typing 'help syntax' -
bash$ gvim some_test :help syntax
If a file type you want to use is not detected, then there are two ways to add it.
Method 1: You can modify the $VIMRUNTIME/filetype.vim file, but this is not recommended as it will be overwritten when you install a new version of Vim.
Method 2: Create a file in $HOME/vim/myfiletypes.vim and put these lines in it -
" " ************************************************************* " Filename : $HOME/vim/myfiletypes.vim " See the document by typing :help autocmd within vim session " see also the doc at /usr/share/vim/doc/autocmd.txt " This file will setup the autocommands for new filetypes " using the existing syntax-filetypes. " For example when you open foo.prc it will use syntax of plsql " Basically does :set filetype=prc inside vim " Add a line in $HOME/.gvimrc as below: " so $HOME/vim/myfiletypes.vim " " ************************************************************* augroup filetype au! au! BufRead,BufNewFile *.phc set filetype=php au! BufRead,BufNewFile *.mine set filetype=mine au! BufRead,BufNewFile *.xyz set filetype=drawing au! BufRead,BufNewFile *.prc set filetype=plsql augroup END
so $HOME/vim/myfiletypes.vim
NOTE: Make sure that you set "so myfiletypes.vim" before switching on file type detection. This is must be before any ":filetype on" or ":syntax on" command.
See the documentation on autocommand at -
Your file will then be sourced in after the default FileType autocommands have been installed. This allows you to overrule any of the defaults, by using ":au!" to remove any existing FileType autocommands for the same pattern. Only the autocommand to source the scripts.vim file is given later. This makes sure that your autocommands in "myfiletypes.vim" are used before checking the contents of the file.
Instead of using "Syntax" menu you can also manually source in the syntax file. Edit the file with gvim and at : (colon) command give 'so' command. For example -
gvim foo.pc :so $VIM/syntax/esqlc.vim
Each syntax file supports one or more default file name extensions, for example, JavaScript syntax file supports the *.js extension. If you happen to use an extension that conflicts with another default syntax file (such as adding JavaScript to a *.html file) than you can source in the additional syntax file with the command :so $VIM/syntax/javascript.vim. To avoid all of this typing, you can create a soft link like -
ln -s $VIM/syntax/javascript.vim js gvim foo.html (... this file contains javascript functions and HTML) :so js
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |