1 " Vim script
 2 " Maintainer: Peter Odding <peter@peterodding.com>
 3 " Last Change: August 31, 2010
 4 " URL: http://peterodding.com/code/vim/profile/autoload/xolox/escape.vim
 5 
 6 " pattern() -- convert a string into a :substitute pattern that matches the string literally {{{1
 7 
 8 function! xolox#escape#pattern(string)
 9   if type(a:string) == type('')
10     let string = escape(a:string, '^$.*\~[]')
11     return substitute(string, '\n', '\\n', 'g')
12   endif
13   return ''
14 endfunction
15 
16 " substitute() -- convert a string into a :substitute replacement that inserts the string literally {{{1
17 
18 function! xolox#escape#substitute(string)
19   if type(a:string) == type('')
20     let string = escape(a:string, '\&~%')
21     return substitute(string, '\n', '\\r', 'g')
22   endif
23   return ''
24 endfunction
25 
26 " vim: ts=2 sw=2 et