Hugo Bois
Hugo Bois

Reputation: 141

How to live update debug code in IntelliJ

I have a code that I would like not to re-run each time I'm changing a single variable on debug, in IntelliJ. This is automatically done on the Eclipse IDE but not using IntelliJ.

How to make the program updating itself without having to re-run it?

Upvotes: 2

Views: 1302

Answers (1)

Hugo Bois
Hugo Bois

Reputation: 141

IntelliJ 2020.2.1


The following process explains how to live update debug code when saving file. This is especially useful if you need to grope around several values in variables, which may turn out to be very annoying if you have to run your code each time you modify it.

  1. Edit > Macros > Start Macro Recording
    (at this point, each one of your action is recorded, so don't click anywhere else than what the list says).
  2. Code > Optimize Imports
    (cleans out unused or duplicate imports)
  3. Code > Reformat Code
    (only if you want your code to be formatted each time you save)
  4. Ctrl+Shift+F9
    (corresponds to the default shortcut for rebuilding necessary files)
  5. File > Save All
  6. Edit > Macros > Stop Macro Recording
  7. Give a name to your macro, like Custom live code update and confirm
  8. Ctrl+Shift+S > Keymap > Macros > Choose yours > Add Keyboard Shortcut > Ctrl+S
    You certainly have already this shortcut assigned to the Save All action. Don't worry, you can override it without problem.

Hope this helped out some of you.

Everytime you save your file with Ctrl+S, it will now rebuild it (and then updating it on-the-fly when on debug run). Let me know if it does not work for you or if you program under other IntelliJ versions.

Upvotes: 1

Related Questions