I often nest one programming language within another (e.g. HTML inside python). This can be done per-language, and written items in
~/.vim/after/syntax/ for that purpose, but I don't have the patience to implement it for every combination I use. This means I press :seUpUp a lot.
One way to script this would simply be
nmap <F12> :set syn=<up><up><cr>
This almost works. The problem is that it's not literal enough; vim doesn't actually put this command in my history, so there's no "toggling" going on. (Actually, this is preferable; I don't want to pollute my history with all of this toggling.)
I'm pretty sure what I need is a custom function that searches my history for the most recent syntax specification (excluding the current syntax) and sets it. I know how to bind a function to a key, but I do not know how to implement the needed vimscript function.
Could somebody provide me some pointers here? Searching the web for this sort of thing merely turns up tricks for searching the command history manually (without vimscript).