Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2015
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. if !exists("g:WindowBufManager")
  2. let g:WindowBufManager= {}
  3. endif
  4.  
  5. function! StoreBufTab()
  6. if !has_key(g:WindowBufManager, tabpagenr())
  7. let g:WindowBufManager[tabpagenr()] = []
  8. endif
  9.  
  10. " add the new buffer to our explorer
  11. if index(g:WindowBufManager[tabpagenr()], bufname("%")) == -1 && bufname("%") != ""
  12. call add (g:WindowBufManager[tabpagenr()],bufname("%"))
  13. endif
  14. endfunction
  15.  
  16. function! WindowBufManagerNext()
  17. " find the next index of the buffer
  18. let s = index(g:WindowBufManager[tabpagenr()], bufname("%"))
  19. if (s!= -1)
  20. let s = (s +1) % len(g:WindowBufManager[tabpagenr()])
  21. execute 'b ' . g:WindowBufManager[tabpagenr()][s]
  22. endif
  23. endfunction
  24.  
  25. augroup WindowBufManagerGroup
  26. autocmd! BufEnter * call StoreBufTab()
  27. augroup END
  28.  
  29. :call WindowBufManagerNext()
  30.  
  31. $ vim file1 file2
  32. :tabnew
  33. :argl file3 file4 file5
  34. :n
  35. :n
  36. gt
  37. :n
  38. gt
  39. :N
  40. and so on…
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement