Skip to content

Instantly share code, notes, and snippets.

@tsukkee
Created March 1, 2011 09:27
Show Gist options
  • Save tsukkee/848892 to your computer and use it in GitHub Desktop.
Save tsukkee/848892 to your computer and use it in GitHub Desktop.
function! s:read_line() dict
let l:output = self.buffer
let l:res = l:output
while l:res !~ '\r\?\n' && !self.__eof
let l:res = self.read(256)
let l:output .= l:res
endwhile
let l:pos = match(l:output, '\v%(\r?\n|$)\zs')
let l:line = matchstr(l:output[: l:pos - 1], '.\{-}\ze\r\?\n$')
let self.buffer = l:output[l:pos :]
let self.eof = (self.buffer != '') ? 0 : self.__eof
return l:line
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment