Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace :while loop with map() and filter() in s:LongLines() #8

Merged
merged 1 commit into from May 24, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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