Auto increment the serial number of a zone file after each edit with vim

Emacs functionality with Vim

Long story short,

I was missing a functionality which i have with Emacs when editing BIND zone files.

By adding the following lines to the zone file header, Emacs will take care of changing the serial number for you.

The “Auto Increment” Function

Testing

A example zone file, Open a zone file and type “Soa”

Please not that you MUST have the serial number in the format of:

The auto-increment function will look for this specific pattern.

The autocmd part

Open you vimrc file and add the following line to it,

  • ┬áThis command will run a autocmd (which calls to the Soa function) each time before (BufWritePre) we write the file to the disk.
  • Also the command with work only on *.zone and *.revzone files under the path “/var/named/chroot/var/named”

Resources

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *