I have a few hotkeys mapped in my .vimrc (see below) for compiling and running autohotkey scripts but I can either be annoyed by the quest for the any key or I can run them silent
and be unaware if there are errors.
autocmd filetype autohotkey nnoremap <S-F5> :w <bar> silent exec '!"C:\Program Files\AutoHotkey\Compiler\Ahk2Exe.exe" /in '.shellescape('%')<CR>
autocmd filetype autohotkey nnoremap <C-F5> :w <bar> silent exec '!"C:\Program Files\AutoHotkey\Compiler\Ahk2Exe.exe" /in '.shellescape('%').' && start .\'.shellescape('%:r')<CR>
autocmd filetype autohotkey nnoremap <S-F6> :silent exec '!Taskkill /IM '.shellescape('%:r').'.exe /F'<CR>
autocmd filetype autohotkey nnoremap <C-S-F5> :silent exec '!Taskkill /IM '.shellescape('%:r').'.exe /F' <bar> silent exec '!"C:\Program Files\AutoHotkey\Compiler\Ahk2Exe.exe" /in '.shellescape('%').' && start .\'.shellescape('%:r')<CR>
How do I have these exec
commands keep the cmd window open only if there is an error?
(e.g. if I run the ctrl+F5 and the compiled version is already running, the compile will fail because it can't write to the .exe. (Yes, I know in that particular case there's an evil modal popup but in other cases, there's not good feedback of failure.))