I'm trying to set a nmap bind to make the focus change from Window B back to Window A. Both Window IDs are store at the script level: s:win_id_a
and s:win_id_b
.
The current snippet I've is the following at plugins/my-plugin.vim:
function! s:InitialSetup
let s:win_id_a = win_getid()
bot new
let s:win_id_b = win_getid()
" bunch of unrelated setups ...
win_gotoid(s:win_id_b) " Making sure we are binding the correct win/buff
map <buffer> c :call win_gotoid(s:win_id_a)<CR>
endfunction
When I tried to trigger the map/bind I got an error: Undefined variable: s:win_id_a
.
The question is: Should I "cast" s:win_id_a
to a global OR is there another way I can achieve this win_gotoid
bind call passing the script level variable?
s:
variables is that they’re local to the script (functions and mappings in the*.vim
file) where they’re defined, right? Is your:map
command defined in the same script that is defining those variables? Please edit your question to add more context on where the variables are defined and where your:map
command lives.