Tuesday, November 22, 2016

Vim Plugin: Subnet Search

Finished the subnet search plugin for vim written in python.  Given a CIDR subnet, it will generate a regular expression to match all ip addresses in that subnet:


In the example above, 10.9.3.0/29 is given as the CIDR subnet, and all the IP addresses within that subnet, including the network number and broadcast address, are highlighted.  If they were spread out amongst the file, just repeating the last search in vim using the '/' key and return will jump to the next occurrence.  Pretty handy in those cases whereby you want to search for or see all the IP addresses within a subnet.  It does go through a list of IP addresses for a subnet, so a /8 or any large subnet may take some time depending on the speed of the machine it's being run on.  It's at vim.org and github. It uses python 2.7, and the backported IP address module.