Seite wählen

NETWAYS Blog

Manage vim with Puppet and use Icinga 2 syntax highlighting

vim is my preferred editor after all. Even I hack Icinga 2 code with vim way faster than any other interface. vim requires some configuration love of course.
Many distributions do not install vim or set it as default editor. In the Git training sessions on Debian/Ubuntu we’ll have a lab for making vim the default for example. Inside the CentOS base box used for the Icinga 2 Vagrant boxes I’ll also ensure via puppet manifest to install the vim package.
Now for the configuration bits – one keeps a local $HOME/.vimrc with own customizations. That works fine for your own workstation but what if you want to automate such setups and distribute a custom vimrc config on all your servers? You could keep just a file and sync that using Puppet manifests of course. But what about the mentioned default editor settings? And you do not want to break anything with a syntax error?
I’ve found this puppet-vim module pretty nifty and helpful. The most recent commit inside the Vagrant boxes uses it already.

class { 'vim':
  opt_bg_shading => 'light',
}

There are many other options available such as setting it as default editor on Debian. To mention some more:

  • opt_nocompatible
  • opt_bg_shading – I prefer a light background, also easier on a beamer for an Icinga Camp demo
  • opt_lastposition – jump to the last position when opening a file. I definitely want that everywhere.
  • opt_syntax – enable syntax highlighting. On older systems or Debian this is disabled by default.
  • opt_misc – sets some interesting default values for incremental search, etc.:
    [‚hlsearch‘,’showcmd‘,’showmatch‘,’ignorecase‘,’smartcase‘,’incsearch‘,’autowrite‘,’hidden‘]

In case you ask – why do you care so much about vim? I wanted to integrate the new Icinga 2 vim syntax highlighting packages into the Vagrant boxes. Just install „vim-icinga2“ (currently snapshot packages, available with 2.5.0) and you’re ready to go. This is also part of our Icinga 2 training sessions helping you to understand keywords and object definitions far more easy.

  package { 'vim-icinga2':
    ensure => 'latest',
    require => [ Class['icinga_rpm'], Class['vim'] ],
    alias => 'vim-icinga2'
  }

Enjoy vim everywhere 🙂
vagrant_icinga2_vim_syntax_highlighting
 

Kurz gebloggt: vim auf schwarzer Konsole

Wer kennt es nicht: Das Blau vom Syntax in vim ist so dunkel, dass man auf einem schwarzen Hintergrund kaum was lesen kann?
Dafür gibt es recht einfache Abhilfe:

:set background=dark

Oder auch eben anders rum:

:set background=light

Und als Tipp sei noch gesagt:

echo "set background=dark" >> ~/.vimrc