aboutsummaryrefslogtreecommitdiff
path: root/vim/autoload/escape.vim
blob: 37ac3e8b4fdb12a7ae9c1fd9d7493d0d0666f97f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
" Escape text for use as an Ex command argument
function! escape#Arg(arg) abort
  return exists('*fnameescape')
        \ ? fnameescape(a:arg)
        \ : escape(a:arg, "\n\r\t".' *?[{`$\%#''"|!<')
endfunction

" Escape text for use as a list item
function! escape#Item(item) abort
  return escape(a:item, ',')
endfunction

" Escape wildcard characters in list items to prevent e.g. tilde or glob
" expansion in the resulting item
"
function! escape#Wild(string) abort
  return escape(a:string, '\*?[{`''$~')
endfunction