vim

Fork of vim, an acceptable text editor
git clone git://git.laack.co/vim.git
Log | Files | Refs | README | LICENSE

ft_mp.txt (4673B)


      1 *ft_mp.txt*	For Vim version 9.2.  Last change: 2026 May 04
      2 
      3 This is the documentation for the METAFONT and MetaPost filetype plugins.
      4 Unless otherwise specified, the commands, settings and mappings defined below
      5 apply equally to both filetypes.
      6 
      7 NOTE: the plugin requires |+vim9script|.
      8 
      9 ==============================================================================
     10 CONTENTS						*mp.vim* *ft-metapost*
     11 							*mf.vim* *ft-metafont*
     12 
     13 1. Introduction				|ft-metapost-intro|
     14 2. Commands				|ft-metapost-commands|
     15 3. Settings				|ft-metapost-settings|
     16 4. Mappings				|ft-metapost-mappings|
     17 
     18 ==============================================================================
     19 							*ft-metapost-intro*
     20 							*ft-metafont-intro*
     21 Introduction ~
     22 This filetype plugin provides extensive support for editing METAFONT and
     23 MetaPost documents, including syntax coloring, indentation, and completion.
     24 
     25 Defining indentation rules for METAFONT and MetaPost code is tricky and
     26 somewhat subjective, because the syntax is quite liberal. The plugin uses some
     27 heuristics that work well most of the time, but in particular cases you may
     28 want to override the automatic rules, so that the manually defined
     29 indentation is preserved by commands like `gg=G`.
     30 
     31 This can be achieved by appending `%>`, `%<`, `%=` or `%!` to a line to
     32 explicitly control the indentation of the next line. The `<` and `>` symbols
     33 may be repeated many times: for instance, `%>>` will cause the next line to be
     34 indented twice. Of course, `%<` means that the next line should be
     35 de-indented; `%=` sets the indentation of the next line to be equal to the
     36 indentation of the current line; and `%!` means that the indentation of the
     37 next line should not change from whatever it has been manually set.
     38 
     39 For example, this is the default indentation of a simple macro:
     40 >
     41 	def foo =
     42 	    makepen(
     43 	        subpath(T-n,t) of r
     44 	        shifted .5down
     45 	        --subpath(t,T) of r shifted .5up -- cycle
     46 	    )
     47 	    withcolor black
     48 	enddef
     49 <
     50 By adding the special comments, the indentation can be adjusted arbitrarily:
     51 >
     52 	def foo =
     53 	    makepen(
     54 	        subpath(T-n,t) of r  %>
     55 	            shifted .5down   %>
     56 	                --subpath(t,T) of r shifted .5up -- cycle   %<<<
     57 	    )
     58 	    withcolor black
     59 	enddef
     60 <
     61 							*ft-metapost-commands*
     62 Commands ~
     63 					*:FixBeginfigs*
     64 Renumber beginfig() blocks in the current buffer so that the n-th figure has
     65 number n. MetaPost only.
     66 
     67 							*ft-metapost-settings*
     68 							*ft-metafont-settings*
     69 Settings ~
     70 					*'g:mf_other_macros'*
     71 Highlight some other basic macro names, e.g., from cmbase, logo, etc. This is
     72 set to 1 by default in METAFONT buffers, and it is set to 0 by default in
     73 MetaPost buffers.
     74 
     75 					*'g:mf_plain_macros'*
     76 Highlight keywords defined by plain.mf. This is set to 1 by default in
     77 METAFONT buffers, and it is set to 0 by default in MetaPost buffers.
     78 
     79 					*'g:mf_plain_modes'*
     80 Highlight keywords defined by modes.mf. This is set to 1 by default in
     81 METAFONT buffers, and it is set to 0 by default in MetaPost buffers.
     82 
     83 					*'g:mp_close_tag'*
     84 Define additional keywords that end indented blocks. For instance, if you
     85 define:
     86 >
     87 	g:mp_close_tag = ['\<endfoo\>']
     88 <
     89 any line starting with `endfoo` will be de-indented compared to its previous
     90 line.
     91 >
     92 	g:mp_close_tag = []
     93 <
     94 					*'b:mp_metafun'*
     95 					*'g:mp_metafun'*
     96 If set to 1, highlight ConTeXt's MetaFun keywords. MetaPost only.
     97 >
     98 	g:mp_metafun = 0
     99 <
    100 					*'g:mp_mfplain_macros'*
    101 Highlight keywords defined by mfplain.mp. MetaPost only.
    102 >
    103 	g:mp_mfplain_macros = 1
    104 <
    105 					*'g:mp_open_tag'*
    106 Define additional keywords that start indented blocks. For instance, if you
    107 define:
    108 >
    109 	g:mp_open_tag = ['\<beginfoo\>']
    110 <
    111 the line following `beginfoo` will be indented.
    112 >
    113 	g:mp_open_tag = []
    114 <
    115 					*'g:mp_other_macros'*
    116 Highlight keywords defined by all base macro packages (boxes, rboxes, format,
    117 graph, marith, sarith, string, TEX). This option affects only MetaPost
    118 buffers.
    119 >
    120 	g:mp_other_macros = 1
    121 <
    122 					*'g:mp_plain_macros'*
    123 Highlight keywords defined by plain.mp. MetaPost only.
    124 >
    125 	g:mp_plain_macros = 1
    126 <
    127 					*'g:no_mp_maps'*
    128 					*'g:no_mf_maps'*
    129 When set, do not define any mapping in buffers with the corresponding
    130 filetype.
    131 >
    132 	g:no_mp_maps = 0
    133 	g:no_mf_maps = 0
    134 <
    135 							*ft-metapost-mappings*
    136 							*ft-metafont-mappings*
    137 Mappings ~
    138 
    139 ]]			[count] vardefs, macros or figures forward.
    140 
    141 [[			[count] vardefs, macros or figures backward.
    142 
    143 ][			[count] end of vardefs, macros or figures forward.
    144 
    145 []			[count] end of vardefs, macros or figures backward.
    146 
    147 ]}			[count] end of blocks (fi, endfor, endgroup) forward.
    148 
    149 [{			[count] begin of blocks (if, for, begingroup) backward.
    150 
    151  vim:tw=78:sw=4:ts=8:noet:ft=help:norl: