tags:

views:

145

answers:

2

In the normal case I use vim's make utility I will set makeprg to the Makefile of the project I'm currently working for. Since usually the project will last for weeks or even longer, I don't need to change the setting of makeprg very often . But sometimes I need to write some "foobar" code either for practicing my c++ skill or for prototyping some primitive ideas in my mind. So whenever I switch to the "foobar" mode of vim usage, I need to comments the original makeprg setting add the new setting as following :

au FileType c set makeprg=gcc\ %
au FileType cpp set makeprg=g++\ %

which is really very very inconvenient . when I back to the "normal project mode" of vim usage, I need to change back to the original setting . back and forth ....

what I want to know from you guys is that : is it possible to make the setting of makeprg temporarily . for example , define a function in which first set a local value of makeprg and then call make before return form the function call automatically restore makeprg to the value before the function call.

+1  A: 
too much php
+1  A: 

It's not exactly what you asked for, but you can set options local to a buffer only. That way you don't have to bother wrapping your functions; just change makepgrp locally on the specific files you want.

                                                        *:setl* *:setlocal*
:setl[ocal] ...         Like ":set" but set only the value local to the
                        current buffer or window.  Not all options have a
                        local value.  If the option does not have a local
                        value the global value is set.
                        With the "all" argument: display all local option's
                        local values.
                        Without argument: Display all local option's local
                        values which are different from the default.
                        When displaying a specific local option, show the
                        local value.  For a global/local boolean option, when
                        the global value is being used, "--" is displayed
                        before the option name.
                        For a global option the global value is
                        shown (but that might change in the future).
                        {not in Vi}
au FileType c setl mp=gcc\ %
au FileType cpp setl mp=g++\ %
ephemient