My vimwiki plugin has
Enter key bound to the function to create a "hyper"-link to another file (and if it already is a link then open the linked file to view/edit).
I want to be able to jump back and forth between wiki files and files in
/tmp/wiki-tag-reports (using a vimscript function I managed to write thanks to help from here) and when I have a file from
/tmp/wiki-tag-reports/some-tag-report.mkd open the Enter key should trigger that vimscript function instead of the vimwiki's usual enter-key function.
Is this a simple thing to do?
I don't know how to approach such a "conditional" loading of vimscript. Currently/previously I was using two separate vimrc's but that doesn't work in this switching-back-and-forth way. There must be some way using just a single vimrc and having some logic in it to check for the file path...? But maybe something else is required? Tips? Suggestions?
I thought I might be able to achieve this via:
" note that DiaryTagBrowser() is defined earlier in the vimrc file autocmd BufRead,BufNewFile /tmp/wiki-tag-reports/*.mkd \ command! DiaryTagBrowser : call DiaryTagBrowser() \ nnoremap <Enter> :DiaryTagBrowser <Enter>
but hitting the Enter key in the tag report still invokes the vimwiki hyperlink function thing.
Is there a problem in this vimscript? Or maybe vimwiki plugin has bound the Enter key in a way that somehow takes precedence over this(and if that's the case then what to do about it?)?
:help map-precedencefor precedence of mappings. Local mappings take precedence. I'd expect Vim wiki's mapping would be a local mapping, but it seems that might not be the case, given your answer of using
nnoremap <Enter>directly in an autocmd fixing it... (?) You can check for that using
:nmap <Enter>to query the mappings to see how they're defined.