aboutsummaryrefslogtreecommitdiffstats
path: root/autoload/xolox/misc/str.vim
blob: 901696ca69a683b2d2277eca64aaf62a60315a9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
" String handling.
"
" Author: Peter Odding <peter@peterodding.com>
" Last Change: May 19, 2013
" URL: http://peterodding.com/code/vim/misc/

function! xolox#misc#str#compact(s)
  " Compact whitespace in the string given as the first argument.
  return join(split(a:s), " ")
endfunction

function! xolox#misc#str#trim(s)
  " Trim all whitespace from the start and end of the string given as the
  " first argument.
  return substitute(a:s, '^\_s*\(.\{-}\)\_s*$', '\1', '')
endfunction

" vim: ts=2 sw=2 et