I have mapped F10 key to execute different programs (pdflatex, python) depending on the file extension.
autocmd Filetype tex map <F10> :lcd %:p:h<CR> :bel ter pdflatex % <CR>
autocmd Filetype python map <F10> :lcd %:p:h<CR> :bel ter python3 % <CR>
If I open a tex file and then press F10, pdflatex is executed. If I then open a python file in a new tab and press F10, python is executed. But now if I now switch back to the tab having the tex file and press F10, python is executed and not pdflatex. Vim is mapping F10 as per the extension of the last opened file and not the extension of the current file. Can someone please help me resolve the issue. Thank you