Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
525 views
in Technique[技术] by (71.8m points)

parameter passing - Build and run with arguments in Sublime Text 2

I'm running on MacOS X and I'm using Sublime Text 2 to code.

I've found the command + B option to build and command + shift + B to build and run.

Is it possible to run a program (or script) and pass arguments. Exemple:

myProg arg1 arg2

Note: I'm using multiple languages (C++, Java, Python), so I hope there is a way to set the arguments for each project and not for all build.

Edit

I want to set the parameters for a program call, a little bit like in eclipse where you can set the arguments when you run your program.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

For each project you can create a .sublime-project file with your specific build_system on it:

{
  "folders":
  [{
    "path": "src"
  }],
  "build_systems":
  [{
    "name": "Run with args",
    "cmd": ["python", "$file", "some", "args"]
  }]
}

This way you don't pollute the global Build System menu and won't have to worry about switching build system as you switch projects. This file is also easy to access when you need to change the arguments:

Cmd-Shift-P > Edit Project

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...