There are two kinds of filters in WinMerge: file filters for filtering files and directories in directory compare and line filters for ignoring lines from files before comparing.
Filters are based on regular expressions (regexps). Each line filter or file filter rule is regexp which is matched against file/directory name or line.
Regexps can be very complex to read. Luckily most file filtering needs are for file extensions so looking at example filters installed with WinMerge should help to modify file filters for most needs.
There are many guides and help sites in Web:
http://www.regular-expressions.info/ Good site devoted for regexps |
http://www.amk.ca/python/howto/regex/ Good HOWTO document for regexps |
http://www.zvon.org/other/PerlTutorial/Output/index.html Tutorial |
http://gmckinney.info/resources/regex.pdf PDF quick reference |
File filter is set of rules saved to one file. Every file and directory is tested against all there rules before comparing. Depending if filter is exclusive of inclusive file or directory matching is excluded from or included to compare.
![]() |
Ignored items have 'Skipped' status in directory compare. User can select them to visible or hidden from 'View' menu. Usually its wise to keep skipped items hidden. |
WinMerge's filtering system allows only one filter set to be active at a time. Active filter set can be selected from Open-dialog or from menu: Tools --> Filters. Also empty filter can be selected when no directories or files are ignored.
Filter files are normal ASCII files, with .flt extension. Filter files must be placed to either:
'Filters' subdirectory in WinMerge program directory. This is recommended place.
'Winmerge/Filters' subdirectory in user profile. This can be used for user personal filter when there are many users. Or if backupping from profile directory is wanted etc.
Filter files supplied with WinMerge contain comments about naming and setting filter to exclusive/inclusive.
Common format for one filter line is like this:
f: \.ext$ ## Match files *.ext or d: \\directory$ ## Match given directory name |
Rule begins with 'f:' if it matches for filenames and 'd:' if it matches for directory names. Filenames are given to filter as is, there are no special characters added. But for directory names WinMerge adds '\' to begin of directory name. This is done clearly to separate directory names and filenames. '##' is a comment separator, all chars in rule after that are ignored by WinMerge.
So simple filters can be for example:
Example 6. Simple filefilter rules
f: \.cpp$ ## Match *.cpp files f: \.h$ ## Match *.h files d: \\test$ ## Match 'test' directories |
![]() |
Don't forget '$' at end. It marks end of directory- or filename and without it rule may not work like expected. While '\.c$' matches with only filenames having extension .c '\.c' matches all extensions beginning with 'c' (.cpp, .com etc). |
Rules can be a lot more complex than those two: this rule matches to CVS generated ".#filename.ext.version" files:
Line filters can be used to ignore single lines from compared files. Line filters are handy when user doesn't want to compare comments or certain generated code. For example version control system (time)stamps.
![]() |
Line filter rule ignores single line it matches. It is not possible to ignore partial lines or several lines with file filter rule. |
In file compare ignored lines are shown with own colors to differentiate them from other differences. User can see these differences but cannot select or merge them.
Line filter rules are regular expressions like file filter rules. Rules can be added and edited in Filters-dialog (Menu: Tools --> Filters). In editbox, give one rule per line.