This question is really two questions.
First question: Does vimscript support having interpolated strings as values in a dictionary?
Second question: Is it possible to remap keys from within a loop? While items is an obvious choice (to me) for creating the loop, I'm open to other loops if they allow this.
" attempted code:
let path_dict = {
\'o.': './',
\'o/': "$p_root",
\'oc': "$p_css",
\'oh': "$p_html",
\'oj': "$p_js",
\'ol': "$p_learn",
\}
for [keybinding, filepath] in items(path_dict)
nnoremap <Leader>keybinding :call Notrw(filepath)<CR>
endfor
" desired result:
" nnoremap <Leader>o/ :call Notrw($p_root)<CR>
" nnoremap <Leader>oh :call Notrw($p_html)<CR>
" nnoremap <Leader>oc :call Notrw($p_css)<CR>
" nnoremap <Leader>oj :call Notrw($p_js)<CR>
" nnoremap <Leader>ol :call Notrw($p_learn)<CR>
" nnoremap <Leader>o. :call Notrw('./')<CR>
execute
. (We may have another question with mappings in a loops but I can't find it right now) – statox Jan 9 '18 at 13:48:exe
command and you can of course create mappings in a loop. – Christian Brabandt Jan 9 '18 at 13:53