开发者

Use last arguments from vim's :make command

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.


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.


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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜