Ifa user is edit a file which contain IP addresses andwouldlike to havethemmarked in a special color,adding the following code intheir .vimrc file will highlight instances of IP addresses in the file being edited.
+
Whenediting a file containing IP addresses,itmaybe helpful to highlighttheaddresses in a special color.Adding the following code to[[vimrc]] will highlight instances of IP addresses in the file being edited.
<pre>
<pre>
syn match ipaddr /\(\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)\.\)\{3\}\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)/
syn match ipaddr /\(\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)\.\)\{3\}\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)/
Line 17:
Line 17:
</pre>
</pre>
−
This will highlight IP Addresses the same way identifiers are highlighted in source code files. This tip uses the following regular expression to find the address to be highlighted.
+
This will highlight IP addresses the same way identifiers are highlighted in source code files. The following regular expression is used to find each address to be highlighted.
created 2005 · complexity basic · author Matous Jan Fialka · version 6.0
When editing a file containing IP addresses, it may be helpful to highlight the addresses in a special color. Adding the following code to vimrc will highlight instances of IP addresses in the file being edited.
syn match ipaddr /\(\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)\.\)\{3\}\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)/
hi link ipaddr Identifier
This will highlight IP addresses the same way identifiers are highlighted in source code files. The following regular expression is used to find each address to be highlighted.