aboutsummaryrefslogtreecommitdiffstats
path: root/autoload/xolox/misc/escape.vim
diff options
context:
space:
mode:
Diffstat (limited to 'autoload/xolox/misc/escape.vim')
-rw-r--r--autoload/xolox/misc/escape.vim40
1 files changed, 25 insertions, 15 deletions
diff --git a/autoload/xolox/misc/escape.vim b/autoload/xolox/misc/escape.vim
index 1dd1838..29a16ca 100644
--- a/autoload/xolox/misc/escape.vim
+++ b/autoload/xolox/misc/escape.vim
@@ -1,11 +1,16 @@
-" Vim auto-load script
+" String escaping functions.
+"
" Author: Peter Odding <peter@peterodding.com>
-" Last Change: November 21, 2011
+" Last Change: May 19, 2013
" URL: http://peterodding.com/code/vim/misc/
-" Convert a string into a :substitute pattern that matches the string literally.
-
-function! xolox#misc#escape#pattern(string)
+function! xolox#misc#escape#pattern(string) " {{{1
+ " Takes a single string argument and converts it into a [:substitute]
+ " [subcmd] / [substitute()] [subfun] pattern string that matches the given
+ " string literally.
+ "
+ " [subfun]: http://vimdoc.sourceforge.net/htmldoc/eval.html#substitute()
+ " [subcmd]: http://vimdoc.sourceforge.net/htmldoc/change.html#:substitute
if type(a:string) == type('')
let string = escape(a:string, '^$.*\~[]')
return substitute(string, '\n', '\\n', 'g')
@@ -13,9 +18,10 @@ function! xolox#misc#escape#pattern(string)
return ''
endfunction
-" Convert a string into a :substitute replacement that inserts the string literally.
-
-function! xolox#misc#escape#substitute(string)
+function! xolox#misc#escape#substitute(string) " {{{1
+ " Takes a single string argument and converts it into a [:substitute]
+ " [subcmd] / [substitute()] [subfun] replacement string that inserts the
+ " given string literally.
if type(a:string) == type('')
let string = escape(a:string, '\&~%')
return substitute(string, '\n', '\\r', 'g')
@@ -23,13 +29,17 @@ function! xolox#misc#escape#substitute(string)
return ''
endfunction
-" Convert a string into a quoted command line argument. I was going to add a
-" long rant here about &shellslash, but really, it won't make any difference.
-" Let's just suffice to say that I have yet to encounter a single person out
-" there who uses this option for its intended purpose (running a UNIX-style
-" shell on Windows).
-
-function! xolox#misc#escape#shell(string)
+function! xolox#misc#escape#shell(string) " {{{1
+ " Takes a single string argument and converts it into a quoted command line
+ " argument.
+ "
+ " I was going to add a long rant here about Vim's ['shellslash' option]
+ " [shellslash], but really, it won't make any difference. Let's just suffice
+ " to say that I have yet to encounter a single person out there who uses
+ " this option for its intended purpose (running a UNIX style shell on
+ " Microsoft Windows).
+ "
+ " [shellslash]: http://vimdoc.sourceforge.net/htmldoc/options.html#'shellslash'
if xolox#misc#os#is_win()
try
let ssl_save = &shellslash