It makes me sad that there is no way to globally s...
# intellij
e
It makes me sad that there is no way to globally set Actions on Save to Reformat Code for all new projects. I'm a professor and will have to tell my students to do that every time they create a project. I hope someone can let me know a workaround or upvote the issue. https://intellij-support.jetbrains.com/hc/en-us/community/posts/7178879949842-Is-there-a-way-to-set-Actions-on-Save-for-all-new-projects-
K 1
šŸ‘ 1
s
OMG YES. THIS. Thank you i was thinking my environment was messed up. This has bothered me b ecause i come to import a new maven project and each time see this is off. I thought it was random because i switch b/w a lot of projects before
actions on save
there is a plugin that is actually more elaborate than this, i think it's called
save actions
. i have thought about switching back to that. it can also do other fun things
šŸ™ 1
e
@sreich Thanks for the commiseration and letting me know about the plugin. Do you know if it works for all projects or needs to be set individually?
s
i'm pretty sure it's global
e
Hallelujah!
s
install it and give it a shot
e
I'm on it!
The settings do not work for new projects. šŸ˜­
s
nooooo
e
I'm going to need to apply for a job at JetBrains unless someone who works there already takes pity on us. https://twitter.com/swaglord__420/status/1377051721655066629
@antonarhipov I see you're a Developer Advocate and one of my closest JetBrains connections on LinkedIn. Can you please help with this? šŸ™
a
@Ellen Spertus ā€œActions on Save to Reformat Codeā€ ā€” I sense some Eclipse habits šŸ™‚
I think it would be much easier for you just to remap the formatting key to Cmd+S/Ctrl+S as you donā€™t push them in IntelliJ anyway because of autosaving feature
I donā€™t have a better workaround šŸ¤· But perhaps the plugin helps
e
Remapping Cmd+S/Ctrl+S is a great idea, although I don't know if young ones are as compulsive about pressing it as I am.
The inability to set it across projects undermines DRY.
a
Another option is to check the correct formatting inspection before commit and then make sure there are no warnings before commit
s
what do you mean, eclipse habits? what would your approach be for code formatting?
a
When you type with shortcuts in Intellij, in most cases your code will end up correctly formatted. Save on actions is the feature in eclipse and most users develop a habit pressing Ctrl+s for saving the file and consequently executing the additional actions. In Intellij, there is just a different shortcut for formatting as saving of files is automatic, so if Ctrl+s shortcut is already so deep in the muscle memory, you can just assign Ctrl+s to reformatting action However, formatting a full file isn't a very good approach anyway. Especially when working on large code bases, in branches, in teams. You can change a line of code and unintentionally reformat a large file, making the change too big for the code review
e
Students will sometimes be pasting in code (from the instructor, not just from Stack Overflow). Having the code automatically properly formatted would save the students and graders lots of grief.
s
@antonarhipov that is why save on actions has the ability to reformat only changed lines. idk about them, i don't use ctrl-s. i auto save and i expect my IDE to reformat my code as i go