CFEngine vim hilighting

Get the highlighting code from, and set it up in a location that will be loaded by default.  I’m partial to making  directory under /usr/local/share, and then linking the files in.

sudo git clone git:// /usr/local/share/vim_cf3
for D in /usr/local/share/vim_cf3/*; \
 do [[ -d $D ]] || continue; \
 sudo ln -s $D/* /usr/share/vim/vim72/$(basename $D)/; \

Add these lines to /etc/vimrc:

" set CFEngine file type
autocmd BufRead,BufNewFile *.cf set ft=cf3
" Default to unfolding all folds on open
autocmd BufRead,BufNewFile * normal zR

I hate having keyword expansion turned on by default.  There’s a parameter provided that you can add to vimrc to turn that off, but just on the principle of the thing, I’d rather have it default to “off” when installed as a global file, and allow individual users to turn it on if they really want to have their editor change things on them.  Here’s a patch against ftplugin/cf3.vim.  It’ll break if the file is updated in git at some point, but my hope is that, one day, I can get Neil convinced that this should be off by default. :)

(update: it was merged in.  The following is no longer needed)

You can run this with copy-paste by running “cat – | patch -p0 cf3.vim” and pasting this in, then hitting +D.

@@ -23,7 +23,7 @@
 " =============== Keyword Abbreviations  ===============
 " disable keyword abbreviations with by adding 
-" "let g:DisableCFE3KeywordAbbreviations=0" to your vimrc
+" "let g:EnableCFE3KeywordAbbreviations=0" to your vimrc
 " Conveniance function ToggleCFE3KeywordAbbreviations
 " mapped to ,i by default to toggle abbreviations off or on
@@ -76,18 +76,18 @@
 " Default abbreviations on
-" to disable let g:DisableCFE3KeywordAbbreviations=1 in ~/.vimrc
-if !exists('g:DisableCFE3KeywordAbbreviations')
-    let b:DisableCFE3KeywordAbbreviations=1
+" to disable let g:EnableCFE3KeywordAbbreviations=1 in ~/.vimrc
+if exists('g:EnableCFE3KeywordAbbreviations')
+    let b:EnableCFE3KeywordAbbreviations=1
     call EnableCFE3KeywordAbbreviations()
 function! ToggleCFE3KeywordAbbreviations()
-    if !exists('b:DisableCFE3KeywordAbbreviations')
-        let b:DisableCFE3KeywordAbbreviations=1
+    if exists('b:EnableCFE3KeywordAbbreviations')
+        let b:EnableCFE3KeywordAbbreviations=1
         call EnableCFE3KeywordAbbreviations()
-        unlet b:DisableCFE3KeywordAbbreviations
+        unlet b:EnableCFE3KeywordAbbreviations
         call DisableCFE3KeywordAbbreviations()

  1. Danny says:

    There’s an updated version of the policy with the “change stuff silently” code (the abbreviation expansion and permission setting) disabled by default in my github fork at, which would be
    “git clone git://”
    and then ignore the last couple of paragraphs.

Leave a Reply