Permalink
Browse files

Merge pull request #8 from Raimondi/patch-2

Replace :while loop with map() and filter() in s:LongLines()
  • Loading branch information...
2 parents 38b4a6d + cd194d4 commit f6290aafdf81685dff29e5b185971a809a08ad7d @scrooloose committed May 24, 2012
Showing with 2 additions and 13 deletions.
  1. +2 −13 vimrc
View
15 vimrc
@@ -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

0 comments on commit f6290aa

Please sign in to comment.