1function! GotoBuf(n) 2 let n = a:n 3 let i = 1 4 let c = 1 5 while i <= bufnr('$') 6 if bufexists(i) && buflisted(i) 7 if c == n 8 execute "buffer! ".i 9 return 10 endif 11 let c = c + 1 12 endif 13 let i = i + 1 14 endwhile 15endfunction 16 17