Keyboard shortcut to comment several lines of code in IntelliJ - java

I already made an investigation about the topic, and actually, you can find the answer in the official documentation of JetBrains or just going to File -> Settings -> Keymap. However, I can't implement that solution, which is CTRL + SHIFT + /.
I don't have a "/" key in my keyboard, but the combination of the number 7 and SHITF makes the "/" key, so what I do is to press CTRL + SHIFT + 7 trying to comment an entire block of code but nothing happens. Doesn't matter if I select English or Spanish in the Prefered Languages panel of Windows, I cannot comment several lines at the same time using that combination.
I know probably I am doing something very very dumb, but honestly, I have been stuck like 20 minutes trying to figure out what I am doing wrong and I am starting to lose any hope.
Sorry for making a dumb question dear folks, but I would really appreciate if you can help me with this.

Just add any keyboard shortcut that works on your system in Settings | Keymap:

Related

Eclipse isn't overwriting parenthesis

This isn't really a coding problem, but more of just an Eclipse problem.
Say you're typing x = (1), Eclipse will make the closing parenthesis for you the moment you type '('
It also normally writes over the closing parenthesis as you are typing as well.
However, for some reason when I'm typing, it doesn't automatically write over it and I'm confused because I'm pretty sure I didn't hit any special setting so I have no idea what to do to revert this.
So normally you'll type x = (1), and it'll show as x = (1), but right now it's showing x(1)). How do I change it back??
Thanks for the help!
Check in the Settings Content Assist for your Editor. It has a setting to overwrite or not. And in my case it specifically mentions you can toggle that with Ctrl Key while the assist is active. The other setting related is Editor -> Typing. It also has some brace-close settings.
1 way to solve this problem is by turning off Automatically Closed parentheses. Open the preferences for editing, then go to Java -> Editor -> Typing and turn off parentheses.

Multiple keypresses only registering sometimes

I have an odd little bug that I can't seem to weed out. I have tried using the debugger in Eclipse, but I still can't seem to figure it out.
Basically, this is a very very basic engine for a platformer. A lot of the code is from a tutorial, but I have been slowly modifying it and making sure it is all working one little step at a time.
Right now, the problem is that when you are holding down right arrow + W + F you jump(W) to the right (Right arrow) and shoot a fireball (F). This works, however if you repeat the process on the left, you do not shoot the fireball.
I have done quite a bit of tracing, tracing when you enter the fireball loop, when you press the button, and a lot of other things. At the moment, it appears that the keypress for the F is not being registered. Of course, this may just be it isn't being updated or something else, I am not sure. I just know that the trace is not called for the key press event.
This seems to be only when the player is doing all three key presses. So normally you can shoot a fireball to the left, that works. I have uploaded the code to codesend, as it is pretty long and I didn't want to bog down Stackoverflow.
I am happy to provide any other of the code documents, I do think these four should be enough but if you think you need more I will be happy to provide it.
Thank you very much for your time.
CODE:
Abstract Class MapObject - Player extends this
Player
RPG Movement - Player movement engine
Level1State - handles the key presses
Please have a look at here. This is what I meant you to do. Kindly see this and let me know if this helped you or if you still have problems.
handle multiple key presses ignoring repeated key

How to get the return type of a method call in IntelliJ?

Normally you would expect just hovering over a method it would show a popup of the return type.
How do you get this information in intellij ultimate?
Hit Ctrl + Q (or ⌃J on Mac) when cursor is on a method declaration or call. It will show you the pop-up you want. As a bonus: Ctrl + Shift + I will display method body as well in a pop-up.
You hover it and hold down CTRL in windows or CMD in Mac
Try Ctrl + Space for quick definitionAlso Ctrl + Shift + P may help
In intellij, Go to Help > Productivity Guide
you will find a list of useful shortcuts to increase productivity
Regarding, this question in mac Press option+command+V to get the list of names that you can choose
Ctrl+ J in mac for getting the documentation
Find screenshots for ease:-
Ctrl+Shift+P works great with extra bonus by highlighting relevant return expression (IntelliJ 2020.2.3 CE)
Hot key for that: Ctrl + Shift + P
Toolbar: "View->Type Info"

Can't find Eclipse shortcut for Renaming

Used to know this, think its something like Ctrl + ??? + F11. Or something.
I have a class member/property that I would like to change the name of. Unfortunately it is sprinkled all over the class, some 100+ references to it. Throughout the various methods.
Eclipse has a shortcut that allows you to click on an identifier, hit the hotkey (whatever it is), and then modify the text composing the identifier. Then, once you click off of that text, it searches and replaces all references of the "old" identifier and replaces them with the new one.
I know I could just do a search & replace. I don't want that. I want the shortcut/hotkey. And its driving me crazy because I can't find it because I don't know what it's called!
Thanks to any Eclipse gurus that can help.
The shortcut combination is ALT + SHIFT + R.
CTRL+SHIFT+L list of all shortcuts.
The key combination is
Alt + Shift + R
The corresponding menu (and context menu) entry is
Refactor > Rename ...
I wanted to specify that the shortcut is Alt + Command + R if you're using Mac OS X.
PC
The shortcut for rename is:
Alt + Shift + r.
And the list of shortcuts will be displayed with:
Ctrl+Shift+L
Mac OS x
The shortcut defined for rename/refactoring will work:
option + ⌘ + R
The option for rename is:
F2
Both are shortcuts defined for Mac, open the Shortcuts List with
Shift + ⌘ + L:
Simply select the file and press F2. The rename option will open. Other option is ALt + Shift + R. But I prefer F2 is much easier way.
For renaming a file, the F2 works in all cases I've encountered.
However my experience shows that refactoring a class or a method can behave differently in different OS and desktop environments and that they may intercept key modifiers and thus render shortcuts ineffective.
However, eclipse is good at accessing its main menu from the keyboard. For instance, in plasma in linux (tested with eclipse 2019-09 and older) renaming is achieved pressing Alt-T, then releasing it and pressing N afterwards. The Alt-T effectively opens up the refactoring menu and the N orders eclipse to rename the selected element. Actually, the whole refactoring menu can be addressed in that manner, this achieving the goal with less friction.
For Mac, use the below keys
OPTION + COMMAND + R

Creating Button Shortcuts with Java like & (ampersand) with Windows Forms

I wish I could word this question better. Partly I just don't know the name of what I'm looking for.
With Visual Studio and Windows forms you can add an ampersand to create a "shortcut" key to a button by pressing Alt + [That Letter]. Like My &Button ... Alt + B would be the shortcut.
Is there an equivalent of this in Java SWING? I am using NetBeans IDE 6.9.1.
Thank you all!
That's called a mnemonic.
Use setMnemonic (javadoc)
See http://download.oracle.com/javase/tutorial/uiswing/components/menu.html#mnemonic
You use JMenutItem.setMnemonic(); I don't think there's a handy-dandy shortcut like the ampersand.

Categories