How to get Puppet code to support vim highlighting

Source: Internet
Author: User
Tags define mkdir root directory

Puppet PP profile has not been vim support, edit the black background white, not easy to row wrong, it seems difficult to distinguish, need to make further changes to perfect display

You must add 2 files to the. Vim in the user's root directory, as follows:

1 Vim directory to create the Syntax/puppet.vim:

#mkdir ~/.vim

#cd ~/.vim

#mkdir syntax

#vim Syntax/puppet.vim

Add the following:

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

"Puppet syntax file
"Filename:puppet.vim
"Language:puppet configuration file
"Maintainer:dongwm<ciici1234@hotmail.com>
"URL:
"Last Change:
"Version:
"

"Copied from the Cfengine, Ruby, and Perl syntax files
"For-version 5.x:clear all syntax items
"For version 6.x:quit when a syntax file is already loaded
If version < 600
Syntax clear
ElseIf exists ("B:current_syntax")
Finish
endif

SYN region Puppetdefine start= "^\s*\ (class\|define\|site\|node\)" end= "{"
Contains=puppetdeftype,puppetdefname,puppetdefarguments
SYN keyword Puppetdeftype class define site node inherits contained
SYN keyword Puppetinherits inherits contained
SYN region puppetdefarguments start= "(" end= ")" Contains=puppetargument
Syn match puppetargument "\w\+" contained
Syn match puppetargument "\$\w\+" contained
Syn match puppetargument "' [^ ']+ '] contained
Syn match puppetargument ' "[^"]+ "' contained
Syn match Puppetdefname "\w\+" contained

Syn match puppetinstance "\w\+\s*{" Contains=puppettypebrace,puppettypename,puppettypedefault
Syn Match Puppettypebrace "{" contained
SYN Match Puppettypename "[a-z]\w*" contained
SYN Match Puppettypedefault "[a-z]\w*" contained

Syn match Puppetparam "\w\+\s*=>" Contains=puppettyperarrow,puppetparamname
Syn match Puppetparamrarrow "=>" contained
Syn match Puppetparamname "\w\+" contained
Syn match puppetvariable "$\w\+"
Syn match puppetvariable "${\w\+}"
Syn Match Puppetparen "("
SYN match Puppetparen ")"
Syn Match Puppetbrace "{"
Syn match Puppetbrace "}"

SYN Region puppetstring start=+ "+ skip=+\\\\\|\\" + end=+ "+ contains=puppetvariable"

SYN keyword Puppetboolean true false
SYN keyword Puppetkeyword import inherits include
SYN keyword Puppetcontrol case default

"Comments last overriding everything else
Syn match puppetcomment "\s*#.*$" Contains=puppettodo
SYN keyword Puppettodo TODO note fixme XXX contained

"Define the default highlighting.
' for version 5.7 and earlier:only ' done already
"For version 5.8 and later:only when a item doesn ' t have highlighting yet
If version >= 508 | | !exists ("Did_puppet_syn_inits")
If version < 508
Let Did_puppet_syn_inits = 1
command-nargs=+ hilink Hi Link <args>
Else
command-nargs=+ hilink hi def link <args>
endif

Hilink puppetvariable Identifier
Hilink Puppetboolean Boolean
Hilink Puppettype Identifier
Hilink Puppetdefault Identifier
Hilink Puppetkeyword Define
Hilink Puppettypedefs Define
Hilink puppetcomment Comment
Hilink puppetstring String
Hilink Puppettodo Todo
"Hilink Puppetbrace Delimiter
"Hilink Puppettypebrace Delimiter
"Hilink Puppetparen Delimiter
Hilink Puppetdelimiter Delimiter
Hilink Puppetcontrol Statement
Hilink Puppetdeftype Define
Hilink Puppetdefname Type
Hilink Puppettypename Statement
Hilink Puppettypedefault Type
Hilink Puppetparamname Identifier
Hilink puppetargument Identifier

Delcommand Hilink
endif

Let B:current_syntax = "puppet"

More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/soft/tools/

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

2. Vim directory to create Ftdetect/puppet.vim

#mkdir Ftdetect

Vim Ftdetect/puppet.vim

Add the following:

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

Au bufread,bufnewfile *.pp setfiletype puppet

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

Effect Demo:

[root@viong]# vim/etc/puppet/manifests/site.pp

Reference Document: http://www.dongwm.com/archives/rangpuppetdaimazhichivimgaoliangxianshi/

This article comes from the "technology is tossing" blog, please be sure to keep this source http://viong.blog.51cto.com/844766/894381

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.