Hi everybody, I have a little problem with pattern matching using Vims' match() function. I`ve wrote a syntax highlighting script for a certain Wiki Syntax, now I want to check via autocommand if the edited text file is a Wiki file:
autocmd BufEnter *.txt call IsWikiSyntax() The function looks like this: fun IsWikiSyntax() if match(getline(1,20),"^ \{0,1}\(=\{2,6}\)[^=]\+\1 *$") >= 0 set textwidth=0 set wrap set linebreak set filetype=wiki endif endfun The pattern used in the match() call is the same as in the syntax highlighting script. The idea is that the function looks for the occurance of the following strings in the first 20 lines and activate change the filetype if it finds a match. The searched strings could be of the type: ====== foo ====== ===== foo ===== ==== foo ==== === foo === == foo == I am a bit confused because the above pattern works for the syntax highlighting part but not for the match() call. I tried several abbreviations of the above pattern on a string via :echo match(line(1),"[pattern]") but always get "-1". Does the match() function interpret patterns in a different way - or am my missing something else? I am using Vim 7.0.174. Thanks in Advance Michael -- Michael Klier
signature.asc
Description: Digital signature