s i s t e m a o p e r a c i o n a l m a g n u x l i n u x | ~/ · documentação · suporte · sobre |
Next
Previous
Contents
3. Color Syntax init files
3.1 Auto source-in methodThis section below is obtained from gvim session by typing 'help syntax' - bash$ gvim some_test :help syntax Click on Menu Window=>Close_Others to close other Window. And then do CTRL+] on 'Syntax Loading Procedure' menu which will take you there. (Use CTRL+T to rewind and go back). If a file type that you want to use is not detected yet, there are two ways to add it. It's better not modify the $VIMRUNTIME/filetype.vim file. It will be overwritten when installing a new version of Vim. Create a file in $HOME/vim/myfiletypes.vim and put these line in it - " Filename : $HOME/vim/myfiletypes.vim " myfiletypefile augroup filetype au! BufRead,BufNewFile *.mine set filetype=mine au! BufRead,BufNewFile *.xyz set filetype=drawing au! BufRead,BufNewFile *.prc set filetype=plsql augroup END Then add a line in your $HOME/.vimrc and $HOME/.gvimrc file to set the "myfiletypefile" variable to the name of this file. (CAUTION: You MUST put this in both vimrc and gvimrc files in order for this to work) Example: let myfiletypefile = "~/vim/myfiletypes.vim" NOTE: Make sure that you set "myfiletypefile" before switching on file type detection. This is must be before any ":filetype on" or ":syntax on" command. Your file will then be sourced 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 "myfiletypefile" are used before checking the contents of the file. 3.2 Manual methodInstead 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 The syntax source files are at /usr/share/vim/syntax/*.vim. Vim supports more than 120 different syntax files for different languages like C++, PERL, VHDL, JavaScript,...and so on!! 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 Next Previous Contents |