sponsor Vim development Vim logo Vim Book Ad

iptables : iptables-save/restore syntax highlighter

 script karma  Rating 73/28, Downloaded by 3717  Comments, bugs, improvements  Vim wiki

created by
Eric Haarbauer
 
script type
syntax
 
description
This vim syntax script highlights files used by Harald Welte's iptables-save
and iptables-restore utilities.  Both utilities are part of the iptables
application (http://www.netfilter.org/projects/iptables).

Features:

  * Distinguishes commands, options, modules, targets and chains.
  * Distinguishes numeric IP addresses from net masks.
  * Highlights tokens that occur only in hand-edited files; for example,
    "--append" and "destination-unreachable".
  * Special handling for module names; for example, the tcp module is
    colored differently from the tcp protocol.

Options:

  Customize the behavior of this script by setting values for the following
  options in your .vimrc file.  (Type ":h vimrc" in vim for more information
  on the .vimrc file.)

  g:Iptables_SpecialDelimiters
    This variable, if set to a non-zero value, distinguishes numeric
    delimiters, including the dots in IP addresses, the slash that separates
    an IP address from a netmask, and the colon that separates the ends of a
    port range.  If not set, this option defaults to off.

Known Issues:

  * Some special argument tokens are highlighted whether or not they are
    used with the correct option.  For example, "destination-unreachable"
    gets special highlighting whether or not is used as an argument to the
    --icmp-type option.  In practice, this is rarely a problem.

Reporting Issues:

  If you discover an iptables file that this script highlights incorrectly,
  please email the author (address at the top of the script) with the
  following information:

    * Problem iptables file WITH ANY SENSITIVE INFORMATION REMOVED
    * The release version of this script (see top of the script)
    * If possible, a patch to fix the problem

Design Notes:

  Part of this script is autogenerated from the output of the iptables man
  page.  The source code for generating the script is available from the
  author on request (see email address at the top of the script).  The
  script should build from source on most Linux systems with iptables
  installed.

  The build system that generates this script strips special CVS tokens
  (like "Id:") so that CVS no longer recognizes them.  This allows users to
  place the script in their own version control system without losing
  information.  The author encourages other vim script developers to adopt a
  similar approach in their own scripts.
 
install details
  Put this file in your user runtime syntax directory, usually ~/.vim/syntax
  in *NIX or C:\Program Files\vim\vimfiles\syntax in Windows.  Type ":h
  syn-files" from within vim for more information.

  The iptables-save and iptables-restore applications do not specify a
  naming standard for the files they use.  However, iptables-save places a
  comment in the first line of its output.  Other applications, such as
  Fedora Core's system-config-securitylevel use the iptables-save/restore
  format, but with a different leading comment.  We can use these leading
  comments to identify the filetype by placing the following code in the
  scripts.vim file in your user runtime directory:
  
     if getline(1) =~ "^# Generated by iptables-save" ||
      \ getline(1) =~ "^# Firewall configuration written by"
         setfiletype iptables
         set commentstring=#%s
         finish
     endif

  Setting the commentstring on line 4 allows Meikel Brandmeyer's
  EnhancedCommentify script (vimscript #23) to work with iptables files.
  (Advanced users may want to set the commentstring option in an ftplugin
  file or in autocommands defined in .vimrc.)
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
iptables.tar.bz2 1.09 2014-06-08 7.0 Eric Haarbauer Updated for iptables 1.4.19.1.
iptables.tar.bz2 1.08 2011-02-19 7.0 Eric Haarbauer Updated for iptables 1.4.9.
ip used for rating: 3.17.74.227

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github