📄 syntax.txt
字号:
| +- Source the user's optional file, from the |myfiletypefile| | | variable. This is where you can add your own connections between | | file name and file type. Or overrule existing ones. *synload-4* | | | +- Install one autocommand which loads $VIMRUNTIME/scripts.vim when | | no file type was detected yet. *synload-5* | | | +- Source $VIMRUNTIME/menu.vim, to setup the Syntax menu. |menu.vim| | +- Install a FileType autocommand to set the 'syntax' option when a file | type has been detected. *synload-6* | +- Execute syntax autocommands to start syntax highlighting for each already loaded buffer.When a file is loaded, its syntax file is found in this way: Loading the file triggers the BufReadPost autocommands. | +- If there is a match with one of the autocommands from |synload-3| | (known file types) or |synload-4| (user's file types), the 'filetype' | option is set to the file type. | +- The autocommand at |synload-5| is triggered. If the file type was not | found yet, then $VIMRUNTIME/scripts.vim is sourced. | | | +- Source the user's optional |myscriptsfile|. This typically makes | | checks using "getline(1) =~ pattern" to find out which file type | | the file is, and sets 'filetype'. | | | +- If the file type is still unknown, check the contents of the file, | again with checks like "getline(1) =~ pattern" as to whether the | file type can be recognized, and set 'filetype'. | +- When the file type was determined and 'filetype' was set, this | triggers the FileType autocommand |synload-6| above. It sets | 'syntax' to the determined file type. | +- When the 'syntax' option was set above, this triggers an autocommand | from |synload-1| or |synload-2|. This will source the syntax file in | the $VIMRUNTIME/syntax directory or the user's syntax file. | +- Any other user installed FileType or Syntax autocommands are triggered. This can be used to change the highlighting for a specific syntax.==============================================================================4. Syntax file remarks *:syn-file-remarks* *b:current_syntax-variable*The name of the syntax that has been loaded is stored in the"b:current_syntax" variable. You can use this if you want to load othersettings, depending on which syntax is active. Example:> :au BufReadPost * if b:current_syntax == "csh"> :au BufReadPost * do-some-things> :au BufReadPost * endif2HTML *2html.vim* *convert-to-HTML*This is not a syntax file itself, but a script that converts the currentwindow into HTML. A new window is opened, in which the HTML file is built. Warning: This is slow!The resulting file can be written where you want it. You can then view itwith any HTML viewer, such as Netscape. The colors should be exactly the sameas you see them in Vim.If you want the lines to be numbered, set the "html_number_color" variable tothe color name of the line number. The color name must be valid in HTML.Example:> let html_number_color = "#804000"To stop this, remove the variable:> unlet html_number_colorRemarks:- This only works in a version with GUI support. If the GUI not actually running (possible for X11) it still works, but not that good (the color names may be wrong).- In older browsers the background colors will not be shown.- From Netscape you can also print the file (in color)!- When 'tabstop' is not 8, the amount of white space will be wrong.Here is an example how to run the script over all .c and .h files from aUnix shell:> $ for f in *.[ch]; do gvim -f +"syn on" +"so \$VIMRUNTIME/syntax/2html.vim" +"wq" +"q" $f; doneAda *ada.vim*This mode is designed for the 1995 edition of Ada ("Ada95"), which includessupport for objected-programming, protected types, and so on. It handles codewritten for the original Ada language ("Ada83" or "Ada87") as well, thoughAda83 code which uses Ada95-only keywords will be wrongly colored (such codeshould be fixed anyway).For more information about Ada, see http://www.adapower.com.The Ada mode handles a number of situations cleanly. For example, it knowsthat the "-" in "-5" is a number, but the same character in "A-5" is anoperator. Normally, a "with" or "use" clause referencing another compilationunit is colored the same way as C's "#include" is colored. If you have"Conditional" or "Repeat" groups colored differently, then "end if" and "endloop" will be colored as part of those respective groups.You can set these to different colors using vim's "highlight" command (e.g.,to change how loops are displayed, enter the command ":hi Repeat" followed bythe color specification; on simple terminals the color specificationctermfg=White often shows well).There are several options you can select in this Ada mode.To enable them, assign a value to the option. For example, to turn one on:> let ada_standard_types = 1To disable them use ":unlet". Example:> unlet ada_standard_types = 1You can just use ":" and type these into the command line to set thesetemporarily before loading an Ada file. You can make these option settingspermanent by adding the "let" command(s), without a colon,to your "~/.vimrc" file.Here are the Ada mode options:Variable Action ~ada_standard_types Highlight types in package Standard (e.g., "Float")ada_space_errors Highlight extraneous errors in spaces...ada_no_trail_space_error but ignore trailing spaces at the end of a lineada_no_tab_space_error but ignore tabs after spacesada_withuse_ordinary Show "with" and "use" as ordinary keywords (when used to reference other compilation units they're normally highlighted specially).ada_begin_preproc Show all begin-like keywords using the coloring of C preprocessor commands.Even on a slow (90Mhz) PC this mode works quickly, but if you findthe performance unnacceptable, turn on ada_withuse_ordinary.Assembly *asm.vim* *asmh8300.vim* *nasm.vim* *masm.vim* *asm68k*Files matching "*.i" could be Progress or Assembly If the automatic detectiondoesn't work for you, or you don't edit Progress at all, use this in yourstartup vimrc:> :let filetype_i = "asm"Replace "asm" with the type of assembly you use.There are many types of assembly languages that all use the same file nameextensions. Therefore you will have to select the type yourself, or add aline in the assembly file that Vim will recognize. Currently these syntaxfiles are included: asm GNU assembly (the default) asm68k Motorola 680x0 assembly asmh8300 Hitachi H-8300 version of GNU assembly ia64 Intel Itanium 64 masm Microsoft assembly (probably works for any 80x86) nasm Netwide assembly tasm Turbo Assembly (with opcodes 80x86 up to Pentium, and MMX) pic PIC assembly (currently for PIC16F84)The most flexible is to add a line in your assembly file containing:> asmsyntax=nasmReplace "nasm" with the name of the real assembly syntax. This line must beone of the first five lines in the file.The syntax type can always be overruled for a specific buffer by setting theb:asmsyntax variable:> let b:asmsyntax=nasmIf b:asmsyntax is not set, either automatically or by hand, then the value ofthe global variable asmsyntax is used. This can be seen as a default assemblylanguage:> let asmsyntax=nasmAs a last resort, if nothing is defined, the "asm" syntax is used.Netwide assembler (nasm.vim) optional highlighting ~To enable a feature:> let {variable}=1|set syntax=nasmTo disable a feature:> unlet {variable} |set syntax=nasmVariable Highlight ~nasm_loose_syntax unofficial parser allowed syntax not as Error (parser dependend; not recommended)nasm_ctx_outside_macro contexts outside macro not as Errornasm_no_warn potentially risky syntax not as ToDo *basic.vim* *vb.vim*Both Visual Basic and "normal" basic use the extension ".bas". To detectwhich one should be used, Vim checks for the string "VB_Name" in the firstfive lines of the file. If it is not found, filetype will be "basic",otherwise "vb". Files with the ".frm" extension will always be seen as VisualBasic.C *c.vim*A few things in C highlighting are optional. To enable them assign any valueto the respective value. Example:> let c_comment_strings=1To disable them use ":unlet". Example:> unlet c_comment_stringsvariable Highlight ~c_comment_strings strings and numbers inside a commentc_space_errors trailing white space and spaces before a <Tab>c_no_trail_space_error ... but no trailing spacesc_no_tab_space_error ... but no spaces before a <Tab>c_no_ansi don't do standard ANSI types and constantsc_ansi_typedefs ... but do standard ANSI typesc_ansi_constants ... but do standard ANSI constantsc_no_utf don't highlight \u and \U in stringsc_syntax_for_h use C syntax for *.h files, instead of C++c_no_if0 don't highlight "#if 0" blocks as commentsc_no_cformat don't highlight %-formats in stringsIf you notice highlighting errors while scrolling backwards, which are fixedwhen redrawing with CTRL-L, try setting the "c_minlines" internal variableto a larger number:> let c_minlines = 100This will make the syntax synchronization start 100 lines before the firstdisplayed line. The default value is 50 (15 when c_no_if0 is set). Thedisadvantage of using a larger number is that redrawing can become slow.When using the "#if 0" / "#endif" comment highlighting, notice that this onlyworks when the "#if 0" is within "c_minlines" from the top of the window. Ifyou have a long "#if 0" construct it will not be highlighted correctly.To match extra items in comments the cCommentGroup cluster can be used.Example:> au Syntax c call MyCadd()> function MyCadd()> syn keyword cMyItem contained Ni> syn cluster cCommentGroup add=cMyItem> hi link cMyItem Title> endfunANSI constants will be highlighted with the "cConstant" group. This includes"NULL", "SIG_IGN" and others. But not "TRUE", for example, because this isnot in the ANSI standard. If you find this confusing, remove the cConstanthighlighting:> :hi link cConstant NONECOBOL *cobol.vim*COBOL highlighting for legacy code has different needs than fresh development.This is due both to differences in what is being done (maintenance versusdevelopment) as well as other factors. To enable legacy code highlighting,add this line to you .vimrc:> let cobol_legacy_code=1To disable it again, use this:> unlet cobol_legacy_codeCYNLIB *cynlib.vim*Cynlib files are C++ files that use the Cynlib class library to enablehardware modelling and simulation using C++. Typically Cynlib files have a .ccor a .cpp extension, which makes it very difficult to distinguish them from anormal C++ file. Thus, to enable Cynlib highlighting for .cc files, add thisline to your .vimrc file:> let cynlib_cyntax_for_cc=1Similarly for cpp files (this extension is only usually used in Windows)> let cynlib_cyntax_for_cpp=1To disable these again, use this:> unlet cynlib_cyntax_for_cc> unlet cynlib_cyntax_for_cppCWEB *cweb.vim*Files matching "*.w" could be Progress or cweb. If the automatic detectiondoesn't work for you, or you don't edit Progress at all, use this in yourstartup vimrc:> :let filetype_w = "cweb"DTD *dtd.vim*The DTD syntax highlighting is case sensitive by default. To disablecase-sensitive highlighting, add the following line to your startup file:> let dtd_ignore_case=1The DTD syntax file will highlight unknown tags as errors. Ifthis is annoying, it can be turned off by setting:> let dtd_no_tag_errors=1before sourcing the dtd.vim syntax file.Parameter entity names are highlighted in the definition using the'Type' highlighting group and 'Comment' for punctuation and '%'.Parameter entity instances are highlighted using the 'Constant'highlighting group and the 'Type' highlighting group for thedelimiters % and ;. This can be turned off by setting:> let dtd_no_param_entities=1The DTD syntax file is also included by xml.vim to highlight included dtd's.EIFFEL *eiffel.vim*While Eiffel is not case-sensitive, its style guidelines are, and thesyntax highlighting file encourages their use. This also allows tohighlight class names differently. If you want to disable case-sensitivehighlighting, add the following line to your startup file:> let eiffel_ignore_case=1Case still matters for class names and TODO marks in comments.Conversely, for even stricter checks, add one of the following lines:> let eiffel_strict=1> let eiffel_pedantic=1Setting eiffel_strict will only catch improper capitalization for thefive predefined words "Current", "Void", "Result", "Precursor", and"NONE", to warn against their accidental use as feature or class names.Setting eiffel_pedantic will enforce adherence to the Eiffel styleguidelines fairly rigorously (like arbitrary mixes of upper- andlowercase letters as well as outdated ways to capitalize keywords).If you want to use the lower-case version of "Current", "Void","Result", and "Precursor", you can use> let eiffel_lower_case_predef=1instead of completely turning case-sensitive highlighting off.Support for ISE's proposed new creation syntax that is alreadyexperimentally handled by some compilers can be enabled by:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -