Skip to content

Commit

Permalink
Merge pull request #8 from Raimondi/patch-2
Browse files Browse the repository at this point in the history
Replace :while loop with map() and filter() in s:LongLines()
  • Loading branch information
scrooloose committed May 24, 2012
2 parents 38b4a6d + cd194d4 commit f6290aa
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions vimrc
Expand Up @@ -225,19 +225,8 @@ endfunction
function! s:LongLines()
let threshold = (&tw ? &tw : 80)
let spaces = repeat(" ", &ts)

let long_line_lens = []

let i = 1
while i <= line("$")
let len = strlen(substitute(getline(i), '\t', spaces, 'g'))
if len > threshold
call add(long_line_lens, len)
endif
let i += 1
endwhile

return long_line_lens
let line_lens = map(getline(1,'$'), 'len(substitute(v:val, "\\t", spaces, "g"))')
return filter(line_lens, 'v:val > threshold')
endfunction

"find the median of the given array of numbers
Expand Down

0 comments on commit f6290aa

Please sign in to comment.