tags:

views:

55

answers:

3

I have a one key mapping to build my project.

noremap <F5> :make<CR>

This works great. However I sometimes am building a only a piece of the project. In this case I use the command :make smaller_part to build just that piece. I'd also like a one key mapping for this use case as well.

noremap <S-F5> :make last_arguments()<CR>

Is this possible? A last_arguments() function isn't required. It's just how I imagine the solution would look. The important part is I hit one key and it runs :make with the arguments that I gave it last time.

+1  A: 

I don't know whether you can programmatically retrieve the last line from the command history, or specific arguments on it. I expect you can, but I don't know how to do it offhand.

But what are the constraints here? If you'll allow your initial invocation of make to call a function you've defined, say :MyMake(smaller_part), then that can save the smaller_part in a variable and you can define a Remake() function that will call make on the target saved in that variable.

Is that solution acceptable to you? Or must the original invocation be of the form :make smaller_part?

profjim
I don't really care how :make is called custom commands would be fine.
caspin
+1  A: 

What if you wrap the :make command in a couple commands of your own? One command runs make with whatever argument you supplied (possibly none). It also stores the argument in a variable. Then you map this command to <F5>. The other command runs make with the argument stored in your variable (again, if any). You map this command to <S-F5>. I think the vim command for defining your own commands like this is Command.

Paul A Jungwirth
How would you call make from a vim function passing the command all of the function parameters?
caspin
+3  A: 

I use

map <f2> :wa<cr>:Make <Up>

to run make with the last arguments by the way

command -nargs=* Make write | make <args> | cwindow 6

is the Make.

skeept
Nice!(And I need many characters for making a comment, wich I think is not that good of an idea, since sometimes a short comment can be positive. Also, the game)
Martín Fixman