Evan Klitzke wrote:
Hi everyone,

I have the F2 key mapped as a "compile" function for the programs I
write, e.g. if I am editing a .tex file I have an autocmd to execute
pdflatex, if I am editing a .py file I have an autocmd to execute
python. The case of .c files is somewhat trickier: I want to use autocmd
to map F2 to :make if a Makefile exists in the current directory,
otherwise it should try to compile the file with gcc. For example, if I
am editing foo.c, hitting F2 should execute "gcc -o foo foo.c". Do you
have any recommendations on how to do this? Particularly I am confused
on how to have a conditional autocmd, and how to extract a substring
from the current buffer/file name.

I have also thought about modifying my existing auto commands to execute
only if the current buffer is unmodified (i.e. has been saved since the
last edit). How would I add such a check to my auto commands?

Thanks in advance!

-- Evan Klitzke



        autocmd EventName * if ! &mod | DoSomething | endif


see
        :help expr-option
        :help :bar
and possibly
        :help line-continuation


Best regards,
Tony.

Reply via email to