Related
I've used AppCode (Intellij C++/ObjC IDE that replaces Xcode) for a while and really gotten used to being able to Ctrl+Click on any identifier to get to its definition/decleration.
Now on a new work place, I'm using CLion for a somewhat larger code base and Ctrl+Click hardly ever works. It only seem to work when the identifier is in the same file.
Is there anything I need to setup for this to work correctly? CLion seem to index the code successfully and doing text searches works fine.
You need to use import project functionality of CLion from File -> Import Project and give ok for CMakeLists.txt file automatic creation. Never mind the file is for CMake, you can build your project with other tools too, but CLion uses it for the dependencies.
Then append in the beginning of that file a line stating:
include_directories(.)
After that go to File -> Settings and there search for Keymap from the left and after that on right, right below the word "keymap" there is a selection element for taking for example Eclipse default keymapping in use and there you have at least (I tested only it) the ctrl + click functionality working like charm!!
kudos about the include_directories(.) goes to this question: CLion indexer does not resolve some includes in the project directory
You need to press ctrl + alt + shift + n.
And after pressing it a dialog box will appear to enter your variable/function name and click enter.
Tip: Filter the result for a better experience. Filter option is present on right side of the dialog box.
To get a quick peek of function/variable definition press ctrl + q while focusing on the variable or function.
To get the detailed or full definition of function press ctrl + shift + i while focusing on the variable or function.
I just looked at one of my more complicated teaching examples with multiple header/source files where this would come up.
What I see is that ctl-click (and the red/green arrows in the gutter) does work only in the same file. But I can right-click on a method from another file and choose to go to either the declaration (in header) or definition (in cpp).
The hotkeys to do this are not ctl-click. But you can remap hotkeys in IntelliJ ides, so you may be able to come up with hotkey combinations that don't seem too awkward to you.
What helped me was to run File > New CMake Project from Sources
Until that point, Ctrl+click in CLion would go to the definitions, but wouldn't find any usages.
What is the equivalent of CTRL + SLASH on german keyboards?
I know that US-Layouts got that / where the german _ is, since I used an US-Layout for some time. But CTRL + _ just collapses a method.
Just use the slash (Ctrl + /) on the numpad.
I found a solution for using the desired shortcut on Intellij Idea.
You just need to:
- click Ctrl+Alt+S to open the settings dialog box,
- choose "Keymap" from the left menu
- then search for keyword "comment".
- right click on "Comment with Block comment" and select add Keyboar Shortcuts.
- Type the shortcut you want to use and click ok.
For more details : https://www.jetbrains.com/help/idea/2016.3/configuring-keyboard-shortcuts.html
I just changed Ctrl + Slash and Ctrl + Shift + Slash to Ctrl + 7 and Ctrl + Shift + 7.
Works as expected, as they are the same key on german keyboards.
Problem is Ctrl + Shift + 7 is used for bookmarking a line, so I have to override this shortcut.
As of today it is still an unresolved IDEA issue, see this
https://youtrack.jetbrains.com/issue/IDEA-16116.
Defining a custom keymap seems to be the best solution.
A little late to the party, but maybe it helps someone...
I'm using Ubuntu 16.04 with the gnome desktop.
I frequently switch between the german and english keyboard layout.
In order to be able to use IntelliJ shortcuts with the english layout I had to change the order of the layouts in my system settings:
(gnome desktop) > settings > keyboard > Input source (top right corner)
There you find all configured input sources. I moved "english" to the top.
Now I can use all shortcuts based on the english layout, even when I switch to german. This means e.g. Ctrl + _ with the german or Ctrl + / with english layout would be line-comment in IntelliJ.
Not really an answer but I found this while googling and unfortunately had to add a custom keymap, too.
I now have it on CMD + ß. The combination is not used (which makes sense due to its QWERTZ relation). Works for me.
I just discovered that STRG(CTRL) + # works for my QWERTZ-Keyboard.
Hope it helps somebody!
It's been almost 4.5 years and I just want to share with you guys, which route I took because of only this issue (more or less). Sorry that this is not an answer in the proper stackoverflow manner.
I switched my keyboard setting to "US - International" and only use this one for everything I do nowadays. You can have the umlauts (by pressing Shift + ä and then your desired letter) on windows and macos. An all the "special keys" feel so much more natural! While you have to do finger-splits for certain characters, they use AT MAX the shift key on US layouts. Feels so much nicer to write and code like that!
I know, this is probably not what you are going to do, but I can tell you, that I find more and more people who did that and not a single one of them regretted that. Obviously that means, that you should be able to type blindly. :) At least, most keyboard I use, don't have the US layout on it. I adapted to it pretty fast though.
So basically, having the umlauts takes a tiny little bit more effort, but this is really worth it, because everything else makes so much sense on the US layout and you will get all the keymaps as they were intended to be used. Not those crappy "translations" that sometimes don't make sense, like this annoying line-comment thingy here.
Update 2021:
Compare how you write those characters on a US layout compared to whichever layout you are using. There are dramatically less keys involved in using those chars and I can write them faster and also with less wear and tear on my fingers.
;
:
/
`
'
#
<>
[]
{}
I also struggle with this shortcut and could'nt find the right combination.
The only solution i found is to change to English keybord layout using Alt+Shift and then use Strg+Underscore for commenting and back to german layout Alt+Shift.
This helps for the moment. Hope for a better solution.
I solved this by changing the shortcut. You can do this the following way:
In Android Studio in the top menu, click on Android
Studio->Preferences...
A new window pops up, in the side menu of it select Keymap. Now
you see a list. Click on Main menu -> Code -> Comment with
Line Comment (doubleclick) -> add keyboard shortcut.
A small window pops up. You can now simply press the shortcut you
prefer and click ok.
Don't forget to save your changes by clicking OK or Apply.
The configured shortcut should work immediately.
Copying over a solution I found in one of the comments in Jetbrain's bug tracker (see https://youtrack.jetbrains.com/issue/JBR-216#focus=Comments-27-4838035.0-0 )
[...]
I found the plugin "Keyboard Nationalizer". Install the Plugin, restart IntelliJ and execute the Action "Generate National Keymap" - that's it.
After generating a German layout, the shortcuts can be used again
If you are on macOS (MacBook, ...) and have a German keyboard you can make the command + / keymap work like this:
Step 1 - macOS settings
Disable the "Hilfemenü anzeigen" ("Open the Help menu") shortcut in the keyboard settings of macOS:
Step 2 - IDEA settings
In the keymap preferences of IntelliJ IDEA (or Android Studio) add the keymap shift + command + 7 for "Comment with Line Comment". Note: I used the "macOS" keymap settings as the basis, and adding a keymap will create your personal copy of the settings.
Now it should work the same way as in Visual Studio Code for example.
In my current version of IDEA v.20221.1.4 there is an option "Use national layouts for shortcuts (require restart)". Activate it, nothing changed.
Then I check the documents of IDEA, it says you need to install the "Keymap Nationalized" plugin to use it. Deatails about this plugin can be found here: https://plugins.jetbrains.com/plugin/14625-keymap-nationalizer
After install this plugin in IDEA. Double click "Shift" button in IDEA, the "search every" windows will be opened. Find the setting for Keymap Nationalized plugin. Now you can choose the language for the keymap. You will see new keymaps were added, for example there is a new keymap for the Comment with line added.
For MacBook Pro & Air, command + shift + 7 works fine in Visual Studio Code.
If you have a numpad, try using command + /(from the numpad). It worked for me.
According to this page navigating between highlighted usages:
(source: jetbrains.com)
can be done using F3 or Ctrl+L and Shift+F3 or Ctrl+Shift+L keyboard shortcuts, to navigate to the next and previous usages respectively.
However these shortcuts are by default used to navigate between search occurences (Ctrl+F), not highlighted usages, and indeed this is how they work. Is there any other way to navigate between highlighted usages using keyboard?
Install the Identifier Highlighter plugin.
It's a must have plugin for IntelliJ, and is always the very first thing I do to a fresh IDEA installation. I can't understand why this hasn't become part of core IntelliJ yet.
I've found on mac that Ctrl + G works for this purpose well. It actually selects the occurrence for you, which is fine for me. Shift + Ctrl + G for the previous occurrence.
On Windows/Linus this should be Alt + J and Shift + Alt + J respectively.
F3 and Shift+F3 work just fine here. Highlighted usages do not differ from search occurrences in this context.
For linux key mapping setup in IDEA go to next occurrence are Ctrl+L.
Alt+J is for selection for next occurrence.
Ctrl+Alt+Up and Ctrl+Alt+Down navigates to the next and previous usages of a highlighted variable in IntelliJ.
I use this functionality of navigating to the next usage of a variable in a file by hot in Visual Studio all the time (Ctrl+Shift+Up and Ctrl+Shift+Down) and was looking for the equivalent in IntelliJ
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
Locked. This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions.
I did a bit of googling hoping to find a post on IDEA shortcuts similar to Jeff's post on Visual Studio shortcuts (Visual Studio .NET 2003 and 2005 Keyboard Shortcuts), but didn't really spot anything that helped. Hopefully the answers to this question will fill the void.
These are some of my most used keyboard short cuts
Syntax aware selection in the editor selects a word at the caret and then selects expanding areas of the source code. For example, it may select a method name, then the expression that calls this method, then the whole statement, then the containing block, etc.:
Ctrl+W
Basic Code Completion, to complete methods, keywords etc.:
Ctrl+Space
Go to Declaration. Use this to navigate to the declaration of a class, method or variable used somewhere in the code:
Ctrl+B
Introduce Variable Refactoring, to create a variable from an expression. This expression may even be incomplete or contain errors. Since version 8, IDEA intelligently selects a likely expression when no text is selected:
Ctrl+Alt+V
Go to Class, to quickly open any class in the editor:
Ctrl+N
To open any file, not just classes:
Ctrl+Shift+N
Comment/Uncomment current line or selection:
Ctrl+/ and Ctrl+Shift+/
Quick JavaDoc Popup to show the JavaDoc of the method or class at the text cursor:
Ctrl+Q (Ctrl+J on Mac OS X)
Smart Type Completion to complete an expression with a method call or variable with a type suitable in the current Context:
Ctrl+Shift+Space
Rename refactoring to rename any identifier. Can look in comments, text files and across different languages too:
Shift+F6
Select in Popup to quickly select the currently edited element (class, file, method or field) in any view (Project View, Structure View or other):
Alt+F1
Highlight Usages in File. Position the text cursor on any identifier without selecting any text and it will show all places in the file where that variable, method etc. is used. Use it on a throws, try or catch keyword to show all places where the exception is thrown. Use it on the implements keyword to highlight the methods of the implemented interface:
Ctrl+Shift+F7
By far my favourite all purpose shortcut is Ctrl+Shift+A
It does a search as you type through all the commands in intellij. Not only that but when you find the command you want it also displays the corresponding shortcut key next to it!
Here are the Intellij IDEA keyboard shortcuts I find most useful (listed in roughly the order of usage for me):
The shortcut I use the most is Ctrl + B (Go to declaration), to see what a method does, where a variable is declared etc. This is almost always followed by Ctrl + Alt + Left to get back to where I was (Ctrl + Alt + Right works to “go forward” again).
A related navigation shortcut is Ctrl + Alt + B, (Go to implementation). Press it when the caret is at the method name of an interface, and you get a pop-up list of all the places where this method is implemented, and you can select which one you want to go to (if there is only one implementation, you go straight there). The same goes for overridden methods.
The opposite of this is Ctrl + U (Go to super-method/super-class). If the caret is at the implementation of a method in an interface (indicated by the little green interface-symbol in the left gutter), this shortcut takes you to the interface itself.
When I want to see all the places where a method or variable is used (which I want to do a lot), I use Ctrl + Alt + F7 (Show usages). This gives you a pop-up list of all the usages, and you can easily navigate to each one. I prefer this over Alt + F7 (Find usages), which gives you the same information, but in a separate pane below.
To find classes, I use Ctrl + N (Go to class), which lets you search using only the capital letters in the class name (“camel humps”), and * as wildcard.
Yet another shortcut I use, both when reading and writing code, is Ctrl + P (Parameter info) at the arguments of methods and constructors, to see the types and names of the parameters.
When it comes to writing code, I use Ctrl + space (Basic code completion) a lot to auto-complete method names, variable names etc (or simply to see which methods are available for a certain object, by trying to auto-complete directly at the dot following the name of the object).
For searching in the current file I use Ctrl-F (Find - probably the least surprising shortcut in this list), F3/Shift + F3 (Find next/previous) to repeat the search, and Ctrl + Shift + F (Find in path) to search in the whole project.
Ctrl + W (Select successively increasing code blocks) is handy when selecting chunks of code. Repeatedly pressing it selects more and more of the code. Useful when searching, indenting, commenting out code etc.
If there are errors in the file, F2/Shift + F2 (Next/previous highlighted error) will jump to them.
I use the sequence Alt + C, N (Show Changes View) to see which files in the project I have modified compared to the subversion repository. To diff the current file against the version in the subversion repository, I use the sequence Alt + C, S, Y (Compare with the Same Repository Version). In the diff view, I use F7/Shift + F7 to navigate between the changes.
When not in the diff view, I use Ctrl + Shift + Alt + Up/Ctrl + Shift + Alt + Down to jump to the parts of the file that have been changed compared to the checked-out version. At each modification point, you see the corresponding part in the checked-out version in a pop-up window.
Finally, I run JUnit tests using Ctrl + Shift + F10.
Edit: One really useful shortcut that I've only started using in the last few months is Ctrl + E. It brings up a pop-up with the 15 most recently used files, and you just arrow down to the one you want and hit enter to navigate to it.
According to the Jetbrains folks, it will have to be these, as they are for the one wearing the shirt: (Got that from Devoxx)
Help\Productivity Guide
It tells you what are the shortcuts you use/don't use and displays usage statistics. It will guide you to the unknown features.
Some of the time savers:
Alt + Enter : show intention actions (like Eclipse quick fix)
Ctrl + Alt + V : introduce variable (never type the left hand side of an assignment again)
Ctrl + Shift + Space : smart completion ( even two levels down since IntelliJ 8 )
Ctrl + W : select succesively increasing code blocks. Kind of obvious but a real time saver!
The Canoo blog contains some (+8) articles on some more advanced IntelliJ keyboard shortcuts.
The Key Promoter and Shortcut keys list plugins are really helpful for (constantly) learning new IntelliJ keyboard shortcuts.
Try using the Key Promoter plugin. That will help in learning the shortcuts.
Couple of shortcuts apart from the above suggestions:
Alt + Ins: Works consistently to insert anything. (Add a new class, method etc)
Ctrl + Alt + T: Surround code block. Another useful stuff.
This is probably dependent on your development environment, but when doing BlackBerry development I code in IntelliJ and still compile and debug through the BlackBerry JDE. Ctrl + Shift + C is vital in this case as it allows you to copy the full path of the file you are currently editing, making it easy to open the file in the separate dev environment.
Yes, Ctrl + Shift + A is the most useful one. It's a meta shortcut
Within the tool:
"Help -> Default Keymap Reference"
(as suggested by krosenvold)
On the Internet: "IntelliJ IDEA Developers Documentation"
Windows, Linux and Mac keyboard shortcut reference cards for versions 8, 7, 6, 5, and 4.5.
(I knew I had seen and used these reference "cards" before! ;-)
One of my favorites (not shown on the JetBrains cards) is "Ctrl+Shift+{Up or Down Arrow}" to move lines/methods up and down in the source code.
See also "Intellij Idea Keyboard Shortcuts" page on Ward's Wiki.
Shift+Delete deletes the entire line (will 'cut' it to clipboard)
Ctrl+Alt+L to reformat and optimize imports
Ctrl+Shift+J to join lines (pull content of next line up to current line).
Alt + Shift + Insert - switches to column selection mode, allowing the selection of rectangular text fragments (columns)
Ctrl + Shift + Backspace - go to most recent code edit. Hit again to go even further back. Very useful when coding something, browsing other classes for a while and then wanting to go back where we left our code.
Ctrl+E - recently opened files
Ctrl+Shift+E - recently edited files
Ctrl+Shift+V - paste one of the previous values from clipboard
One of my real favorites may not count as a keyboard shortcut exactly. But the "iter" smart template is really great.
basically if you want to iterate though something using a for loop type "iter" then tab to use the live template
itertab
it will figure out the most likely variable you want to iterate over and generate a for loop for it. I'm pretty sure it uses the nearest reference to an object which supports iteration.
Ctrl + F11 invokes a dialog with all alphanumeric keys on the keyboard. Selecting one empty will add the current line to bookmarks and mark the line with selected key.
Shift + F11 invokes a list of bookmarks. Pressing a key takes to associated bookmark.
Ctrl + Shift + Enter - automatically completes the code statement you are typing, inserting the quotation marks, brackets, curly braces and other punctuation as necessary.
F7 F8 F9 for debugging
If you are coming from Eclipse:
http://tanu.wordpress.com/2010/09/24/moving-from-eclipse-to-intellij-idea/
General documentation and shortcuts are on Intellij's site
http://www.jetbrains.com/idea/documentation/index.jsp
Any combination of Ctrl + Alt + Shift and N.
Ctrl + Shift + T in idea8 is also excellent.
There is a complete keymap in the online help too.
Ctrl + N : Open class.
Alt + F7 : Find usages.
http://www.jetbrains.com/idea/docs/ReferenceCard70_mac.pdf has everything you need. after a while, you'll develop your own preference for certain shortcuts.
This link has everything you need. Plus in Idea 8 atleast, every shortcut is completely customizable, so it's really up to you what the most useful ones are.
Idea 8 reference PDF
Just downloaded the CodeRush trial version and I can't easily find the one feature that I really wanted. I would like to be able to start typing a class name and to jump to its definition, sort of like the quick navigator but I want it to search in closed files within my solution as well as open ones. I know R# has that ability, I assume CodeRush does too.
1) Ctrl + Shift + Q (this will bring up the Quick Nav)
2) Start typing the name of the Type, Variable, etc.
3) Hit Enter to select when the target shows in the top of the list
If the scope is not already set to "Solution" (you can tell via the drop-down on the right of the Quick Nav), you can hit Alt + Shift + S to set and it will save the state.
A quick remark to the excellent answer by Troy, if the version you downloaded is the newer one, 3.2, the Quick Nav has been remapped to Ctrl + Shift + Q.