Skip to content

Instantly share code, notes, and snippets.

@mattn
Last active September 23, 2015 14:48
Show Gist options
  • Select an option

  • Save mattn/571731 to your computer and use it in GitHub Desktop.

Select an option

Save mattn/571731 to your computer and use it in GitHub Desktop.
setbufline.vim
function! SetBufLine(expr, lnum, text)
let oldnr = winnr()
let winnr = bufwinnr(a:expr)
if oldnr != winnr
if winnr == -1
silent exec "sp ".escape(bufname(bufnr(a:expr)), ' \')
silent call setline(a:lnum, a:text)
silent hide
else
exec winnr.'wincmd w'
silent call setline(a:lnum, a:text)
endif
else
silent! call setline(a:lnum, a:text)
endif
exec oldnr.'wincmd w'
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment