Disable auto-search in intellij's console when typing the search keyword - intellij-idea

When searching for a String in Intellij's console, you have to type the word you are looking for in a special input. But as soon as you begin typing, intellij is beginning to parse the whole console log which can be huge (it can freeze the whole IDE), and it starts to look for the first letter typed.
So if you want to search for "WARN", it begins to look for "W" for no reason. Is there a way to have a manual "start search" in intellij console and to disable the "auto-search" on typing in search box? That way I would just type the whole word and then search for it in the log, as the word is more restrictive the search would not freeze intellij.

I found how to bypass auto-search, use a text editor (notepad++, scite...) then type in it what you want to look for. Copy it to the clipboard. Paste then in the search box instead of all characters in it (use ctrl+a to select all, then paste).
Intellij will take the paste event as an unique event (not a succession of many keyboard events).

Related

Change behavior of Ctrl-C,Ctrl-F,Ctrl-V in intelliJ IDEA

Most programs copy selected text (say selectedText1), open textbox and paste buffer in search when Ctrl-C, Ctrl-F, Ctrl-V hotkeys are pressed. IntelliJ decided change this behavior to "more efficient". Ctrl-C, Ctrl-F copy-paste highlighted text in a search box.
I end up pressing Ctrl-C, Ctrl-F, Ctrl-V -> selectedText1selectedText1 0 results -> Backspace several times -> selectedText -> too many results, because selectedTextProcessor and selectedText2 are included.
This breaks workflow.
AutoHotKey script to replace ^F with ^F, ^A, Backspace is my current workaround.
Is there a way to tell intelliJ that I want conventional ^c,^f,^v behavior? For instance enable "if ^F,^V are pressed, first ^V is omitted.
No there's no way to do that. The whole point is this way is more efficient.
Your claim about "most programs" and "conventional behaviour" is spurious. Most that I use will default to searching the text on the clipboard, if there isn't already text selected in the current window.

PhpStorm: Disabling autofill on Find

A few versions ago, PhpStorm (and I assume WebStorm) added a new feature: Pressing CTRL+F (Find) while having text highlighted, automatically puts that text in the search bar:
Unfortunately, after decades of habit, I automatically press CTRL+C, CTRL+F, CTRL+V and invariably end up with this:
Before anyone suggests I simply adapt and change, I'd like to point out that no other application I use behaves this way, and I don't want to develop a habit that will only cause me pain in other applications.
How can I disable this "helpful" feature in PhpStorm?

How can I enter a literal <TAB> character in IntelliJ/IDEA/PyCharm?

My configuration indents with four spaces, and I want to keep that. Occasionally (e.g. in a Makefile) I want to input a literal TAB character.
How can I force the IntelliJ-IDEs to input a tab or space, when it would not do so when I hit tab or space in that instance?
You seem to be asking two questions here:
1. How do I force IntelliJ IDE to input a tab, when it would not do so when I hit tab?
and
2. How do I force IntelliJ IDE to input a space, when it would not do so when I hit space?
I don't understand how the second case can arise. However, I have provided a solution to it as well.
Case 1. Insert a tab character when an IntelliJ IDE wants to replace it with spaces due to configuration
Solution
Use search and replace.
Details
Place the cursor where you want the tab to be
Press the X key
Select the X you just typed
From the main menu, choose Edit | Find | Replace to bring up the search and replace pane
Make sure there is an X in the search field
Enter \t in the replace field
Be sure the option Regex is checked
Be sure the option In Selection is checked
Click the Replace button
Case 2. Insert a space character when an IntelliJ IDE won't just let you type one (???)
Solution
Use search and replace.
Details
Place the cursor where you want the space to be
Press the X key
Select the X you just typed
From the main menu, choose Edit | Find | Replace to bring up the search and replace pane
Make sure there is an X in the search field
Enter a single space into the replace field
Be sure the option In Selection is checked
Click the Replace button
Install the plugin for Makefile support: https://plugins.jetbrains.com/plugin/9333-makefile-support
When I tried it today, this automatically use hard tabs in the editors for Makefile files.
Open another text editor, type a tab, and then copy and paste into the PyCharm editor. In MacOSX this worked for me using both Sublime Text 2 and TextEdit.
I can't think of any "direct" way. Probably the easiest way that I can think of is to write a Live Template to do it. See the help page on Live Templates for more information. When you write it, you may need to copy and paste a tab character in from another application.
However, when I tried it, IDEA saw it as just empty text and would not save it. So I used a variable with the "capitalize" function to capitalize a tab character.
Here's the template I created that you can paste into your templates. Now I type tab, hit the Tab key and I get a tab character. Of course you can change the abbreviation.
<template name="tab" value="$TAB$" description="Enter a tab Character" toReformat="false" toShortenFQNames="true">
<variable name="TAB" expression="capitalize(" ")" defaultValue=" " alwaysStopAt="false" />
<context>
<option name="OTHER" value="true" />
</context>
</template>
You could extend the idea to have multiple ones that enter multiple tabs. For example tab to enter 1 tab, tab2 for 2 tabs, etc.
Screenshot of it after use:
There may also be a way to hack a macro to do it. You could then assign the macro to a keyboard shortcut. I'll see if I can figure something out and update this if I do.
Use the menu option: Edit -> Convert Indents -> To Tabs.
Whenever I edit a makefile I do the "to tabs" conversion before I save the file.
UPDATE: Really sadly, I think the generated character still gets converted to spaces... Am checking...
There is an Action in JetBrains IDEs to enter a Tab character.
Here are the steps to use the Tab character action: (discovered in PyCharm 2020.3)
Double-tap the Shift key OR Help -> Find Action...
Type the 3 characters tab
Click on the action that is called Tab and shows the icon for the Tab character...
It remembers the last action you did, so if you have several tabs to add, you can get into a quick process by doing ShiftShift then Return each time.
Answer based on #Morfic's comment to the question. I think this is the cleanest and most sensible reply here so I figured it deserves a place as an answer (and needless to say, it worked for me).
If they're different types of files you could configure File -> Settings -> Editor -> Code style -> Tabs and Indents for each one to use either space or tab depending on how you want it.
One way to do this is to copy a TAB character from another text editor, then right click in your PyCharm file and use Copy / Paste Special -> Paste as Plain Text (Ctrl+Alt+Maj+V)
I guess this was not available in older PyCharm versions, because no other answer proposed it. Regular paste (Ctrl+V) doesn't work (replaced by spaces), but this one works. The function will also bypass other automatic formatting.
Inspired of Clare's suggestion,
assign the left tab key after finding 'tab' action.
At Actions tab, search by 'tab' and move your up/down arrow key and place there.
Then type Ctrl+1, you will see a popup. Select as follows and click OK.
Then, you might be asked "Do you want to remove other assignments?" if Tab key was already assigned. Click Leave because your usage won't conflict with the existing setup.

IdeaVIM: How do I conveniently rename a variable I extract?

In IdeaVIM, if I extract a variable and want to name it, it seems like I'm in visual mode (the name of the variable is highlighted), yet I can't figure out a way to change what's highlighted. Here's an image:
If I type c, it doesn't do anything. If I type cc, it changes the whole line. Basically, it acts like I'm in command mode yet the name is highlighted as if it's in visual mode. What I want to do 99% of the time is change this word. Yet, the cursor is annoyingly one character after the word so ciw doesn't change it.
What's a convenient way to rename this variable? I've normally done hciw. I'd prefer that "extract variable" put me directly into insert mode, though.
It's a little counterintuitive, but the easiest thing to do is just immediately hit i to enter insert mode, then start typing the new name, and it will replace the highlighted text.
The problem, as I see it, is that vim is modal and vanilla IntelliJ is also modal, and what you have here is the interaction of two sets of modes. To understand the IntelliJ modes, try turning off IdeaVIM with ^Z and use the extract variable refactoring. Notice how if you start typing right away, what you type replaces the selected text, but if you move the cursor first and then start typing, what you type is inserted at the cursor. Now add IdeaVIM to the mix: once you are in insert mode, IntelliJ's behavior kicks in.
See VIM-274 for a request to change this behavior and some discussion of alternatives.
For "Extract Variable" once you've got to the point where it's suggesting names:
What always works is pressing Escape, b, cw and then typing the new name.
Sometimes you can press b right away, but often that puts me into visual mode for some reason, so pressing Escape is guaranteed.

Wrapping comments with line breaks in PyCharm

I have comments that gets balloon (PEP 8: Line too long ... > 120)
I wish there was a command that will wrap the lines with few keystrokes.
Right now, even if I type Alt+Enter and press enter on Reformat file, nothing actually changes. Is there a setting or plugin I could use to accomplish the formatting easily?
Under the Edit menu, there is a Fill Paragraph option, which does what I believe you want. You can assign a key command to this in Preferences, under Appearance & Behavior -> Keymap (search for "fill").
Personally, I choose first stroke Esc, second stroke Q, because that's what I've always used in Emacs...
Firstly, reformatting won't work, not in Python at least, where whitespace is important. PyCharm's "Wrap when typing reaches right margin" option is what you're looking for. Now this will not work when you copy and paste code, but in the places where it gives you trouble, just press enter, and it will work.
To be able to auto-reformat comments (and code, for that matter) to honor a right margin after the fact, go into Project Settings under Code Style and then further under Python. Click the Wrapping and Braces tab, and check the "Ensure right margin is not exceeded" checkbox.
Now if you select a region of lines and then run the Code/Reformat Code... command, PyCharm will do its best to wrap the comments or code appropriately.
You will probably have to do some tweaking of the results to suit your stylistic taste. For example, I wish PyCharm would do aggressive filling of text in block comments, at least optionally so.
PyCharm will not reformat code such that it becomes invalid Python, so sometimes it will still leave a line longer than the margin (120 or whatever you set under Project Settings/Code Style/General).
With recent PyCharm this now is located at "Editor -> Code Style", with the checkbox named "Wrap on typing"
The Screenshot shows PyCharm version 2016.2.1 Professional.
Updated Answer:
Use "soft wraps." You can search for it in the help bar.
View > Active Editor > Use Soft Wraps
It won't work for existing text or text that's copied in, but will for any newly typed text.