How to select a text and put it directly on the search and replace bar of IntelliJ - intellij-idea

I'm an IntelliJ user since years and I work on a Mac.
For a long I was able to execute like an automata the following procedure:
select a portion of a text in a file using the mouse
pressing a combination of keys
seeing the selected text in the find & replace bar of the IDE.
Now, I can't remember how to do it.
I have search through the docs of the search & replace in a file, but I cannot see that option.
Just to avoid confusion, the toolbar I'm talking about is the following

I am using IntelliJ on linux (Keymap : Default for xwin) and to select text I use Ctrl+W or Mouse double click. Then ctrl+R will put this text in replace text box

Probably it's a kind of bug. It should work by selecting the text and pressing cmd+r.
Cases when it works:
I select a piece of text in a line and I press cmd+R.
I select the whole line (including white spaces/tabs at the beginning)
Case when does not work:
I select a line from the first character to the last.
More context. I use IntelliJ 2017.2.5 on Mac Os Sierra.

Related

Why is Intellij IDEA highlighting text in standard out like a hyperlink?

I am printing out the contents of a shapefile with ordinary printf statements and for some reason Intellij IDEA Ultimate is underlining and coloring blue a fragment of the output as though it thinks it is a hyperlink:
If I hover the mouse over the blue text, the cursor changes to a finger, like it is a hyperlink. Of course, nothing happens if I click it because it is obviously not a hyperlink. What is going on?
It seems to have something to do with the colons. If I delete them, then the text is no formatted. Also if I use only one colon like this:
X: -71.545101 Y 42.345041
Then there is also no formatting. Only if both colons are present does the blue underlining appear.
org.jetbrains.plugins.groovy.execution.filters.GrCompilationErrorsFilterProvider does that using the following pattern: (file:)?(^|[\W])(?<file>(?:\p{Alpha}\:|/)[0-9 a-z_A-Z\-\\./]+): (?<line>[0-9]+).*
Report a bug or disable Groovy plugin.

Select current line in intellij

Is there any way to select the whole line at caret in IntelliJ 15? I know you can select the current word (ctl + w), go to beginning/end of line but I can't find a current line selection feature.
Simply hit
ctrl+c
Note that for this to select the whole line, you need to ensure that nothing is already selected; otherwise it'll work as an usual "copy" command.
move caret to line
on Windows, press ctrl+shift+a .
This popup appears, where you find Select Line at Caret
for quick access, you can specify a shortcut in Settings
I would like to also add the following from JetBrains website. Because, that what i was looking for here, but no one mentioned it.
1- To select text from the current caret position to the beginning/end of
the current word:
Ctrl+Shift+Left, Ctrl+Shift+Right.
2- To select text from the caret
position to the beginning/end of the current line:
Double-click Ctrl and press Home/End
3- To select text from the current
caret position to the top/bottom of the screen:
Ctrl+Shift+Page Up, Ctrl+Shift+Page Down.
If none of the above are working, I suggest using end and home keys in combination with shift allowing you to select lines quickly.
Go to the end of the line and hit Ctrl+W. If you'll hit Ctrl+W at the beginning of the line it will select only one word.
Not a keyboard feature, but nice to use:
to select the whole row just click on row number on the left of the code.
In addition to that you can click and drag selection.
Moreover, you can doubleclick on the number of the first line of method which results selection of the whole method.

Adding spaces in multiple lines simultaneously - in Pycharm

I occasionally need to go line-by line and change the indentation of the code.
Is there a shortcut in Pycharm where I can add spaces (format the indent) in the begining of multiple lines simultaneously without processing each line individually?
Highlight/ select the lines you want indented, then press TAB as often as needed until they reach the proper indent level.
You can remove spaces with SHIFT TAB.
You can also use CTRL+ALT+I to auto-indent the selection.
Select the block that you want to indent then press TAB. It will work.
To auto indent all the codes in Pycharm just press these sequencies:
CTR + A to select all the text files and then press
CTRL+ALT+I
Select all that you want to indent, then do CTRL+ALT+I to indent all of it. This should work in Pycharm
Use shift +alt on windows machine
Continuation indent for Mac pro: Preferences -> Editor -> Code Style -> the language -> Tabs and Indents
If Ctrl + ALT + I is not working and every time needs to press the Insert button to get the pointer.
So go to Tools -> Select Vim if it is checked then it will be disabled.
Now you can intend code directly selecting multiple lines.

IntelliJ navigate to next and previous highlighted variable

In IntelliJ 10.5 I have "Highlight usages of element at caret" enabled. When a variable/method/etc is selected, is there a way to move to the next and previous occurrence? I'm looking for the equivalent of Control-K in Eclipse.
Edit: Shortcut to navigate between highlighted usages simply moves to the next text occurrence, which is different than moving to the next occurrence of the variable/method/etc. If I have the variable foo selected, I want to navigate to the next occurrence of foo and not any piece of text called "foo" (including "foo" in comments, method names, etc).
Also, pressing F3 seems to be buggy. When I press F3, it sometimes searches using the previous searched text and not the currently highlighted text.
F3 or shift+F3
ctrl+c, ctrl+f, enter or up and down arrows
ctrl+alt+F7
Added this in case people don't look at your edit.
It's not currently possible, see my question: Shortcut to navigate between highlighted usages.
I even created an issue IDEA-70523 addressing this feature, please vote for it if you can't live without it like me :-).
Install Identifier Highlighter Reloaded and use Alt + Shift + Up/Down (can be redefined in Keymap settings) :)
After you give it a shot and notice the 'hey, the highlight stays there after I move my cursor out of it' annoyance, consider upvoting this issue :)
In the Mac OS, you can navigate to next highlighted usage by press control + option + up/down arrow.
Vote this request up for make them implement the feature.
http://youtrack.jetbrains.com/issue/IDEA-59638
I found something thay may more suite your needs : alt + mouse-wheel up/down.
It goes to previous / next occurrence of identifier under caret.
Shortcut name is "Go to next highlighted element usage".
I usually do the following:
Highlight the word
Cmd + F (it will highlight all the matches in file)
Cmd + G (next match)
Cmd + Shift + G (previous match)
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.
Identifier Highlighter Reloaded also does not behave like Eclipse.
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
Look for next occurrence # Keymap
^G = "select" the variable that you want to search for
[shift]⌘G = [previous]next occurrence of selected variable
All credits to #Igor Wojda for his comment in the accepted answer.
(AFAIK, limiting search scope to only variable/method is not possible)
For text based match and quick jump:
Simply place the cursor over the desired word to be searched
Press Ctrl+F3
For further down/up search, simply use
F3/Shift+F3 respectively
in Intellij shortcut for this action, it's not defined.
but you can define it like this:
Ctrl+ Alt + S
search " highlighted usage"
then you can set a shortcut for that.
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

Make IntelliJ reformat the current line on line-completion

Is there a way to have my line reformatted upon completing it in IntelliJ? (For those familiar, this kind of feature is available on FlashDevelop.)
Let's says I just entered this code in PHP:
$var=array("a","b","c");
Upon entering the semicolon, I would like the editor to reformat it to (or whatever my configuration states):
$var = array("a", "b", "c");
This auto-reformat trigger could also be executed on brackets and other line-terminators characters.
There is no such feature in IDEA. You can use Reformat Code (Ctrl + Alt + L) action when needed.
You can actually do something like.
Go to where you want to insert ;
Tools/Start Macro Recording
Type in ;
Then select Code/Auto Indent Lines
Tools/Stop Macro Recording
Name the macro "reformat"
Now go to settings, Keymap, Macros, select "reformat"
Assign a keyboard shortcut of ;
You may have to play with it a bit to get your cursor in the right spot after the macro runs.
This is based on jhormans answer above and i know that the question is more than 6 years old. But IntelliJ IDEA 2017.1.5 still does not have a feature that automatically reformats the current line when semicolon is pressed like VisualStudios.
The workaround is to create a macro as described by jhorman but after pressing ';' run Code -> Reformat Code. Then stop recording and under Settings/Keymap/Macros add the shortcut "Shift+Comma" to the macro. Now when typing the semicolon by pressing Shift + Comma in the code, the code will be reformated aswell. The only shortcoming: the whole code will be reformated each time Shift+Comma is pressed. This may take a second on large files.
This workaround will only work if you just have one line terminator like semicolon. To automatically reformat the code on multiple line terminators (closing brackets, semicolon, ...) you would need to add the shortcuts to "Settings" -> "Keymap" -> "Main Menu" -> "Code" -> "Reformat Code" directly. In this case there's no need to create a macro.
Just formatting the current line isn't possible as far as i know.