how to find only java files in intellij? - intellij-idea

I use CTRL + SHIFT + N shortcut in Intellij to find specific Java files but it also shows .class files; i need to see only .java files. Is there any solution to exclude .class files from CTRL + SHIFT + N ?

You can filter the results using the little blue filter icon in the top right of the window:
Choose as few or as many as you need.

Related

Google Colab: edit two lines at the same time

In my local jupyter-notebook i can edit mutliple lines of code at the same time: simply press ctrl + click at the respective lines. In google Colab that does not seem to work. Is this feature available somehow?
I work with Firefox on a Ubuntu 16.04.
It's available. Instead of Ctrl + Click, please use
Alt + Click for Windows
Option + Click for MacOS
To select all occurrences of the current selection, please use
Ctrl + Shift + L for Windows
Command + Shift + L for MacOS
(In Linux - Chromium, at least)
I managed to do block select but only on contiguous lines, not multi-cursor unfortunately.
Shift+Alt + Up/Down to select multiple lines.
Now you can release Alt and use Left/Right to move to the sides. Whatever you do now will affect the whole block.
And, if you select one or more lines with Shift (doesn't need to be the whole content, this affects all the lines with cursor), and then release Shift and press Alt+Up/Down, you will move those lines altogether up/down
By Rainer Glüge: On Linux+Firefox:
Block-Select: Ctrl+Shift+Alt+Cursor Keys.
Multi-Cursor: Alt+Click
Multi-Select: Select one occurence, then Ctrl+Shift+L
Simplest way:
You can just press Shift+Ctrl+Up/Down keys.
(Tried with Ubuntu + Google Chrome).
Shift+Alt also works, but I find Shift+Ctrl easier.

Intellij search all files (ctrl + shift + f) doesn't find all matches? Settings issue?

Using intellij search all files (crtl + shift + f) it seems to only find the first 100 matches.
Is there a setting I need to change for it to find all matches?
I am not quit sure there is a facility .
But you can use Open in find window option to see all of your matches

What is the shortcut to find next occurrence of a word in IntelliJ IDEA?

In Eclipse the keyboard shortcut to find next occurrence of a word in a file was Ctrl + k . It finds the occurrence of the selected word in a file one by one in a loop. What is the equivalent keyboard shortcut for IntelliJ IDEA? If not can we configure it some how?
First you'll have to highlight a symbol by pressing Ctrl+Shift+F7.
Then you just press F3 or Shift+F3 no navigate between the highlighted symbols.
When done you press Esc to exit the highlight searching.
It is all described on Highlightning Usages in IntelliJ Web Help.
Add selection for the next occurrence on Linux Alt+J
Finding Word at Caret: Ctrl+F3.
On Mac it's Command + G, but you can check what works for your OS by looking at Edit -> Find -> Find Next....
AFAIK you have to select the word in the search bar first.. So, Command + F and then Command + G to go to the next occurrence.
In Android Studio 1.4, apparently Mac OS default keyboard shortcuts for element next occurrence (vars, methods, etc) are
NEXT/FWD: Command+G
PREVIOUS: Shift+Command+G
I did try all the answers w/out success, and finally I looked it up in Prefs->Key Bindings
There are also hotkeys for navigating next/previous highlighted usages.
Several years ago they were Alt+Wheel down and Alt+Wheel up. Today they are not set by default.
You can find them in Keymap preferences with highlighted element usage search phrase.
Please consider using the Multiple Selections for this:
Select the term you want to lookup;
Use Alt+J / Shift+Alt+J (or Ctrl+G / Shift+Ctrl+G for Mac OS X) to select other occurrences.
It will work the same as Shift+F3, but it will select every next occurrences. I found this way much more conveniant, as you can choose to edit all the matching string or just move the cursor to edit the last selected one (←/→).
The Multiple Selections feature is available since IntelliJ IDEA 13.1 RC, and compete with Atom or Sublime Text similar feature.
I could not get any of IntelliJ's native options for Find Next/Previous to behave like in Eclipse. Find Word at Caret comes close, but it only allows you to slurp and find the next word, not previous.
I wrote an IntelliJ plugin to reproduce the exact behavior as in Eclipse. You can find it here: https://plugins.jetbrains.com/plugin/10635-quick-find-plugin
you can set shortcuts same as in eclipse by setting keymap value as eclipse.
Steps in intellij:
Go to setting in file
search for keymap
In the dropdown section set Eclipse
Now all your shortcuts are same as in eclipse.
For MAC:
First you'll have to highlight a symbol by pressing Command+Shift+F7.
Then for next occurrence Command+G or Command+Shift+G
On my Mac it is:
ctrl-l to find next occurrence
ctrl-shift-l to find previous occurrence
IntelliJ Keyboard Shortcuts
On Ubuntu:
Next occurrence of selected word: F3
To expand the question slightly, the method to display the next occurrence of a search term in the Find In Path pane, is to steer to it using the up/down arrows and then hit Enter.
Start by looking for all occurrence of the key (control + g)
Then use ( shift + command + g ) to find previous occurrence and ( command + g ) to find next occurrence.
For those who use IdeaVim plugin, there is another option.
Add these entries into .ideavimrc:
map <C-j> <Action>(GotoNextElementUnderCaretUsage)
map <C-k> <Action>(GotoPrevElementUnderCaretUsage)
This maps the navigation to the next/previous element under caret using ctrl+j/ctrl+k. Of course you can map it to something else, but this suggestion follows the standard navigation keys in vim.

How to reindent lines in IntelliJ IDEA / WebStorm?

In Eclipse, I can select a few lines and press Ctrl + I to reindent those lines. How do I do the same in IntelliJ IDEA / WebStorm?
Note:
I don't want to "indent" or "unindent" the selected lines - that would "move" the text to the right or to the left manually. I want the IDE to be clever about how to position the lines.
I don't want to reformat anything, i.e. there should be no modifications to characters beyond the first non-whitespace character on every line.
Code | Auto-Indent Lines (Ctrl+Alt+I in Windows default keymap).
On a mac, it's Ctrl+Option+I by default.
What worked for me on mac was
⌘ + OPTION + L
Windows:
Ctrl + Alt + L
Mac:
⌘ + OPTION + L
In Webstorm the option can be found as "Reformat Code" in the keymap.
The default on Mac is Alt Cmd l

How to have the formatter wrap code with IntelliJ?

I'm not able to format my code in IntelliJ.
I can see the margin line (by default at 120 columns) but it seems that the activation from the menu:
Code -> Reformat Code
is just ignoring this margin.
IntelliJ IDEA 14, 15, 2016 & 2017
Format existing code
Ensure right margin is not exceeded
File > Settings > Editor > Code Style > Java > Wrapping and Braces > Ensure right margin is not exceeded
Reformat code
Code > Reformat code...
or press Ctrl + Alt + L
If you have something like this:
thisLineIsVeryLongAndWillBeChanged(); // comment
it will be converted to
thisLineIsVeryLongAndWillBeChanged();
// comment
instead of
// comment
thisLineIsVeryLongAndWillBeChanged();
This is why I select pieces of code before reformatting if the code looks like in the previous example.
Wrap when typing reaches right margin
IntelliJ IDEA 14: File > Settings > Editor > Code Style > Wrap when typing reaches right margin
IntelliJ IDEA 15, 2016 & 2017: File > Settings > Editor > Code Style > Wrap on typing
Do you mean that the formatter does not break long lines?
Then please check:
Settings / Project Settings / Code Style / Wrapping
Update:
In later versions of IntelliJ, the option can be found under:
Settings / Editor / Code Style
There select Wrap when typing reaches right margin.
Enabling "Ensure right margin is not exceeded" doesn't work for me in Intellij IDEA 2018.2. I have found the workaround, we need to change every elements below from "Do not wrap" to "Wrap if long".
After that, we can preview what kind of wrap type will be changed by looking into right panel. If we are satisfied, Click "OK" or "Apply" to apply the changes. Finally we need a mannual format by using CTRL+ ALT+ L in Windows and Command+ Shift+ L in MacOS.
Or you can use the shortcut:
Ctrl + Alt + L
In order to wrap text in the code editor in IntelliJ IDEA 2020.1 community follow these steps:
Ctrl + Shift + "A" OR Help -> Find Action
Enter: "wrap" into the text box
Toggle: View | Active Editor Soft-Wrap "ON"
In the latest IntelliJ, version 2020, we have an option called soft-wrap these files:
Settings > Editor > General > soft-wrap these files.
Check this option and add the type of files you would like to apply the wrapping to.
Related question on JetBrains' IDEs Support Forum: Wrap code to indent
You can create a macro for Ctrl +Shift + S (for example) that do all this things:
Edit > Macros > Start Macro Recording (the recording will start). Click where you need.
For example:
Code > Reformat Code
Code > Auto-Indent Lines
Code > Optimize Imports
Code > Rearrange Code
File > Save All
... (all that you want)
Then, click on red button in bottom-right of the IDE to stop the Macro recording.
Set a macro name.
Go to File > Settings > Macros > YOUR MACRO NAME.
Right Click > Add Keyboard Shortcut, and type Ctrl + Shift + S.