*usr_44.txt*	 Vim version 6.2.   : 2002 Oct 10

		  VIM -  

		      


   Vim        
 .      ,     ,
   ,       
 .   |:syn-|  .

|44.1|	  
|44.2|	 
|44.3|	 
|44.4|	 
|44.5|	 
|44.6|	     
|44.7|	 
|44.8|	
|44.9|	     
|44.10|	
|44.11|	    
|44.12|	   

  : |usr_45.txt|   
 : |usr_43.txt|	  
      : |usr_toc.txt|

==============================================================================
*44.1*	  

     ,  Σ    
 .       
$VIMRUNTIME/syntax  ,        
.  ,        
. 

 Σ    .     
        : >

	:syntax clear

     ,     
. 

     ݣ  .     ,
      ,    
  ,     .


  

    ,  : >

	:syntax

    ̣     .
        . 
     ,     , 
      .
       ̣  ,
 : >

	:syntax list {-}

         ( 
|44.8|).      @.


 

      ,  Pascal. 
,  C,   .     
     : >

	:syntax case match
	:syntax case ignore

 "match" ,  Vim    
     .   , "int"
   "Int"  "INT".    "ignore"
   : "Procedure", "PROCEDURE"  "procedure"
       .
    ":syntax case"       
     ,   . 
        :syntax case 
  ; ,      ,
   ,    , 
    ":syntax case"   ,   .

==============================================================================
*44.2*	 

       . 
     : >

	:syntax keyword {} {-} ...

{}    .    ":highlight" 
  {}      .   
  {-}.   : >

	:syntax keyword xType int long char
	:syntax keyword xStatement if then else endif

     "xType"  "xStatement".  , 
     ,    
.         x.  
    "csh"     
"cshType".  ,      
'filetype'.
        "int", "long"  "char"  ,
  "if", "then", "else"  "endif" -- .    
   x    Vim.    
 : >

	:highlight link xType Type
	:highlight link xStatement Statement

 Vim     "xType"   
"Type",    "xStatement"    "Statement". 
  .  |-|. 


  

,    ,      
'iskeyword'.    ,      
,       . Vim    
  - .
     x      '-'. , ģ 
: >
>
	:setlocal iskeyword+=-
	:syntax keyword xStatement when-not

  ":setlocal"     'iskeyword'
   .    ,     
    ,  "w"  "*".    , 
      
 (   ).

 x      . , "next"
   "n", "ne"  "nex".     
  : >
>
	:syntax keyword xStatement n[ext]

       ,     
  "nextone".

==============================================================================
*44.3*	 

       .
,        .   
   .   
,     ,    : >

	:syntax match xIdentifier /\<\l\+\>/
<
	:
	     
	. ,     "if", "then"  .. 
	   ,      ":syntax
	keyword",   ,       
	 xIdentifier.

    ,  ,   
 .      //,   ,
,   ":substitute".     
,  ++  "".

     .   x 
 ӣ,  ,   #   : >

	:syntax match xComment /#.*/

        ,  
        
.     . : ||. 

==============================================================================
*44.4*	 

    x      ("). 
 ,     . 
    ( )    ( 
).   : >

	:syntax region xString start=/"/ end=/"/

 "start"  "end"  ,    
   .     ,   , 
 ?

	"    (\") " ~

   :       
    .    
,         
 .      "skip": >

	:syntax region xString start=/"/ skip=/\\"/ end=/"/

      ,   
     .

       
 ?     ,  
    ,    
.         
"start".       "end"   --  
 . ,       
 "end",    .  , 
          
 ,  ޣ    .

==============================================================================
*44.5*	 

   :

	%Get input  TODO: Skip white space ~

     TODO ֣ ,   ,  
  ,   .  Vim  
,     : >

	:syntax keyword xTodo TODO contained
	:syntax match xComment /%.*/ contains=xTodo

      "contained",  
,        
 .      "contains=xTodo".
 ,      xTodo.  
      xComment  
,   TODO     xTodo 
 ֣ (       
xTodo).


 

 x     .    
   .      : >

	:syntax region xBlock start=/{/ end=/}/ contains=xBlock

, ,      :

	while i < b { ~
		if a { ~
			b = c; ~
		} ~
	} ~

 xBlock    {   .   
  {.      xBlock,  
    xBlock,      
.  "b = c"    .    
 },      xBlock,  
    .  }   
,       xBlock. ,  } 
  xBlock.


 !

     : >

	:syntax region xComment start=/%/ end=/$/ contained
	:syntax region xPreProc start=/#/ end=/$/ contains=xComment

 ,      %   
 .     #    
.       
"contains=xComment",        
 .    ,    :

	#define X = Y  % Comment text ~
	int foo = 1; ~

,       xPreProc.   ?
       ,   
   "end=/$/".
     ,  ޣ   . 
   %     .   
   . Vim    ,
     .
      ,  ޣ  
""  ,   "keepend".  
      : >

	:syntax region xComment start=/%/ end=/$/ contained
	:syntax region xPreProc start=/#/ end=/$/ contains=xComment keepend


  

    contains    ,   
    . : >

	:syntax region xList start=/\[/ end=/\]/ contains=ALL

       xList  
 ,      xList,  , ,
    xList,     . 
       ,       
. : >
>
	:syntax region xList start=/\[/ end=/\]/ contains=ALLBUT,xString

   ,  xString.  TOP 
  ,     "contained". 
CONTAINED, ,     , ̣
  "contained".  . |:syn-contains|.

==============================================================================
*44.6*	     

   x    :

	if (condition) then ~

        . ,
"(condition)"  "then"       ,   
  .    : >

	:syntax match xIf /if/ nextgroup=xIfCondition skipwhite
	:syntax match xIfCondition /([^)]*)/ contained nextgroup=xThen skipwhite
	:syntax match xThen /then/ contained

 "nextgroup"   ,    , ,
,   .       
 ,    ģ. ,  :

	if not (condition) then ~

 "if"   xIf.  "not"   
  xIfCondition,    "if".

 "skipwhite"  Vim,     
  .  : "skipnl" (
    )  "skipempty" (
  ).  ,  "skipnl"  
 ,    -  .

==============================================================================
*44.7*	 

MATCHGROUP

        
̣  . ,      
   xInside,  : >

	:syntax region xInside start=/(/ end=/)/

 ,      - . 
        
,        
"matchgroup".    Vim      
    (      xParen):
>
	:syntax region xInside matchgroup=xParen start=/(/ end=/)/

 "matchgroup"      ,   
  .     ,    
    xParen.     
 , ̣    xParenEnd   : >

	:syntax region xInside matchgroup=xParen start=/(/
		\ matchgroup=xParenEnd end=/)/

    "matchgroup"   , 
          
.       "transparent".


TRANSPARENT

  C       ()   "while" 
,       "for".     
      ,   
.  ,  ,     ()
    ).      :
>
	:syntax region cWhile matchgroup=cWhile start=/while\s*(/ end=/)/
		\ contains=cCondNest
	:syntax region cFor matchgroup=cFor start=/for\s*(/ end=/)/
		\ contains=cCondNest
	:syntax region cCondNest start=/(/ end=/)/ contained transparent

        cWhile  cFor. 
cCondNest      ,      
       . 
   "transparent".
    ,   "matchgroup"     
,    .     "matchgroup"?
ӣ   ,     "matchgroup"  ,
 ޣ          
   .    ,   
cCondNest  (    "while"  "for".  
,          )  
  .   cCondNest    
   (.




,        ()  
"if",          "if",   . 
      . : >

	:syntax region xCond start=/if\s*(/ms=e+1 end=/)/me=s-1

   start -- "ms=e+1". "ms"  Match Start, 
.       . ,  
    ,    
  . "e+1"       
  .
      end   "me=s-1". "me"  Match End,
 . "s-1"      
  , . ,      .
 ,  :

	if (foo == bar) ~

 "foo == bar"    , ̣  
xCond.

    : |:syn--|.


ONELINE

 "oneline"   ,     .
: >

	:syntax region xIfThen start=/if/ end=/then/ oneline

 ,     "if"   
"then",     .

	:
	   "oneline"    ,
	        end. 
	  "oneline" Vim    
	  end,    ,   
	,    end    .


   

    ӣ   .   
  ,     #    
   . ,    \ 
    .   
   , ģ  : >

	:syntax region xPreProc start=/^#/ end=/$/ contains=xLineContinue
	:syntax match xLineContinue "\\$" contained

  ,  xPreProc     ,
  ţ  xLineContinue     
 . ,      
 :

	#define SPAM  spam spam spam \ ~
			bacon and spam ~

   ӣ  ,   .     
,          
 "excludenl"    contained. ,   
"end"   xPreProc,     .   xPreProc 
   ,    xLineContinue,  
 "excludenl": >

	:syntax region xPreProc start=/^#/ end=/$/
		\ contains=xLineContinue,xPreProcEnd
	:syntax match xPreProcEnd excludenl /end$/ contained
	:syntax match xLineContinue "\\$" contained

"excludenl"     .   "xLineContinue"
  "excludenl",     
 xPreProc   ,   .

==============================================================================
*44.8*	

  Σ      ,   ,
      . Vim  
  ,  .
   ,        ,
 if,  while  .        
 :   .     : >

	:syntax match xFor /^for.*/ contains=xNumber,xIdent
	:syntax match xIf /^if.*/ contains=xNumber,xIdent
	:syntax match xWhile /^while.*/ contains=xNumber,xIdent

,          
"contains=".       , 
 ģ  .      
,      
 .
        ,    
 ,   : >

	:syntax cluster xState contains=xNumber,xIdent

        
  .       
 @.  ,      
  : >

	:syntax match xFor /^for.*/ contains=@xState
	:syntax match xIf /^if.*/ contains=@xState
	:syntax match xWhile /^while.*/ contains=@xState

        add: >
	
	:syntax cluster xState add=xString

        remove: >

	:syntax cluster xState remove=xNumber

==============================================================================
*44.9*	     

 C++    C.     
       C  C++,     
  C      C++.   
: >

	:runtime! syntax/c.vim

 ":runtime!"    "syntax/c.vim"  ,   
'runtimepath'.       
 C.      c.vim   
,           
  C++.
         C,  
,      C++. ,  
,     C: >

	:syntax keyword cppStatement	new delete this friend using

      ,       
 . 

     Perl.    ,  
   :    POD    
 Perl.  POD   "=head"   "=cut".
         POD     
      ,    
  Perl.  ":syntax include"   ,
̣       .  Perl 
  : >

	:syntax include @Pod <sfile>:p:h/pod.vim
	:syntax region perlPOD start=/^=head/ end=/^=cut/ contains=@Pod

   Perl  "=head",    perlPOD.  
   @Pod.  ,  , ̣ 
    pod.vim     . 
   "=cut",        
, ̣   Perl.
    ":syntax include"  ,   
    ":syntax clear",    "contains=ALL"
   , ̣  ޣ  , 
  ,     .
   "<sfile>:p:h/"     (<sfile>),   
  (:p)       (:h),    
,    .     pod.vim 
  ,    .

==============================================================================
*44.10*	

   --         .
 Vim   .      ,
   .      
?
    :   ":syntax sync".   
Vim    . ,    Vim
          C  
    : >

	:syntax sync ccomment

        
.  "minlines"  Vim    ,
  ,  "maxlines"   
 .
   ,    Vim     10 
   : >

	:syntax sync ccomment minlines=10 maxlines=500

         
 ,  Vim   ӣ     
,           .  
   500 .   "maxlines"
  ,       
    . 
      ,    Vim 
    .    , 
        
 "display".
          
Comment.      - ,   
  : >

	:syntax sync ccomment xAltComment

       ,  
      .  
  Vim        
     .    Vim
    150      : >

	:syntax sync minlines=150

  "minlines"     Vim,  
  .
   ,     ,   
 ,   : >
>
	:syntax sync match {--}
		\ grouphere {-} {}

   Vim,    {}  
 {-}.      
{--}. ,    sh  if
   "if"    "fi":

	if [ --f file.txt ] ; then ~
		echo "File exists" ~
	fi ~

   "grouphere"   , 
 : >

	:syntax sync match shIfSync grouphere shIf "\<if\>"

 "groupthere"  Vim  ,   .
,   if/fi  : >

	:syntax sync match shIfSync groupthere NONE "\<fi\>"

   NONE  Vim,      
-  .  ,    
 . 

         "grouphere" 
"groupthere".      . ,
     {},    
  : >

	:syntax sync match xSpecial /{.*}/

     : |:syn-sync|.

==============================================================================
*44.11*	    

      ,    
"syntax"    ,   'runtimepath'.  Unix   ,
,  "~/.vim/syntax".
           
  ".vim".    x    :

	~/.vim/syntax/x.vim ~

 ,     ,    
 Vim. . |43.2|.

     ,      
  Vim.     , 
,          .
       Vim: <maintainer@vim.org>.
 ,     .  ӣ  
,  ,      ޣ   
  Vim!


    

    ,      
.          
    ,       ,  
     .    
  ,     Vim --   
        Vim.
          :syntax,  
    . ,    
    C: >
>
	:syntax keyword cType off_t uint

     ,     .  
   "c.vim".     ,  
      'runtimepath'.    
    .  Unix   , ,

	~/.vim/after/syntax/c.vim ~

==============================================================================
*44.12*	   

  ,   Vim    
.        
  .

   ,       , 
         Σ.    
   , ţ ӣ    . : >

	"   Vim
	" :			C
	" :		Bram Moolenaar <Bram@vim.org>
	"  :	2001 Jun 18
	" :		    C++.

   ,     .   
,        . 

      .    
  .      :   
  :    "name.vim", 'filetype',
b:current_syntax,     (nameType,
nameStatement, nameString)  ..

    "b:current_syntax".   ,  
,      ,  ,  
'runtimepath' - .   Vim 5.8,  
: >

	if version < 600
	  syntax clear
	elseif exists("b:current_syntax")
	  finish
	endif

 "b:current_syntax"      . 
,      ޣ ,    
  ,   ģ   "b:current_syntax".

  ,       Vim 5.x,  
  v:version.     yacc.vim.

    ,    . 
   'tabstop', 'expandtab'  .. ӣ  
    ,    . 

    .    'iskeyword'
   ,       . 

   .    
    .  ,   
   ,        8
. 
    Vim 5.8   : >

	if version >= 508 || !exists("did_c_syn_inits")
	  if version < 508
	    let did_c_syn_inits = 1
	    command -nargs=+ HiLink hi link <args>
	  else
	    command -nargs=+ HiLink hi def link <args>
	  endif

	  HiLink nameString	String
	  HiLink nameNumber	Number
	  ... etc ...

	  delcommand HiLink
	endif

 ,     ,  
"display",         
CTRL-L.

==============================================================================

 : |usr_45.txt|   
 : . |___|  

vim:tw=78:ts=8:ft=help:norl:
