I'm writing a plugin where I have several buffers open in split panes ( let's call them small panes ). The user can navigate between the small pane using the usual ctrl+w , wincmd etc ways. While I have another larger pane ( let's call it the large pane ), into which the buffer moved to should get automatically loaded. I have the following script to do this :
let g:current_buff=1 let g:loading_buffer=0 function! ActionOnWindowSwitch(...) if g:loading_buffer == 0 let g:current_buff = bufnr("%") echo g:current_buff if g:current_buff != 1 let g:loading_buffer=1 :wincmd k :buffer g:current_buff :wincmd p let g:loading_buffer=0 endif endif endfunction au BufEnter * call ActionOnWindowSwitch()
But when I run this, I get the error :
E94: No matching buffer for g:current_buff
I have verified by hardcoding the
g:current_buff value that the script works in terms of loading the buffer etc. The problem seems mostly in variable substitution. Or that's what is my best guess. Any ideas how this can be fixed ?