Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run the current file in IntelliJ?

I've recently tried to switch from Eclipse to IntelliJ as a debugger for my university course, and I'm really enjoying the auto-completion, Chronon backwards debugging and other nice features. But there's one thing that bugs the living hell out of me: I just want to run the current file!

In Eclipse, the "Run" button was intelligent enough to simply run the current file if it contained a main method, and use the last-ran file otherwise. But in IntelliJ, just running a file is much more complicated. You have to create a Run Configuration of the right file, and then select that Run Configuration, instead of just opening the file you want. This is a big hassle for me, especially since I have many different classes with main methods in most homeworks and projects.

I found that on Macs, Ctrl + FN + Shift + F10 will "Run Context Configuration", which is almost what I'm looking for. But for some reason, this key binding doesn't have an equivalent toolbar button that switches to the context configuration and just runs it, which would solve all my problems! Can anyone help me out?

like image 581
rosstex Avatar asked Oct 31 '14 07:10

rosstex


3 Answers

I can't find a "Run current file, otherwise selected context" action. I did find them separately.

Key binds for "Run current file":

  • Run context configuration
  • Debug context configuration
like image 113
Mark Jeronimus Avatar answered Sep 19 '22 08:09

Mark Jeronimus


If you hover over the Run and Debug buttons you'll see the shortcuts. Given you're on a Mac OS and Fn is important to trigger F buttons here's the shortcuts:

Run: Shift + Fn + F10

Debug: Shift + Fn + F9

like image 41
dimitrisli Avatar answered Sep 20 '22 08:09

dimitrisli


Years later, the simple answer: Right click inside the file and hit "Run"!

like image 29
rosstex Avatar answered Sep 17 '22 08:09

rosstex