When I write my code in NetBeans, there are times when I want to add/remove if statements and loops. However, every time I want to add/remove a statement but keep the content, I have to fix all the indenting for the contained code. Likewise, every time I try to paste code into a statement, the indenting is all messed up and I have to fix it.
Is there any way to highlight the code and fix indentation?
I'm aware that Eclipse has an option to fix all formatting upon saving. I'm not looking for something that changes formatting upon saving, rather only something I can click on the moment I want the formatting fixed. I put an example of what I'm talking about below.
if (condition == true){
//pasted code
//pasted code
//pasted code
}
or
//other code
//removed if statement
//original code that is spaced too far right
//original code that is spaced too far right
//removed }
//other code
Try to paste using Ctrl + Shift + V. If it worked, look at the netbeans options to configure the shortcut you want. To change shortcuts go to : Tools > Options > Keymap
Here is a table of defaults shortcuts in netbeans : https://netbeans.org/project_downloads/usersguide/shortcuts-80.pdf
It might be useful, you can notice the "Ctrl-Shift-V Paste formatted" shortcut.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With