Making "Search Everywhere" in PHPStorm similar to Sublime Text 3 "Goto Anything" - intellij-idea

I'm making the switch over from ST3 and I would like to replicate one of the search behaviours that I frequently used in ST3.
When I used Sublime Text 3, I would frequently press Ctrl + P to bring up the "Goto Anything" panel.
It looks like this:
As you can see, the ST3, uses fuzzy string matching to match any path and file name in your project.
So for example typing
ze vi help will match any file which contains that sequential list of characters in it's file path.
On the other hand, when you use PHPStorm for "Search Everywhere" it only searches the class name or the file name.
Is there a way to include this functionality? I would like PHPStorm to search the filepath and filename, rather than the PHP class names in the files.

If you miss a fuzzy file search like the one in Sublime, please vote for IDEABKL-6959

You can use double shift, it is called "search everywhere"
What I did, I remapped double shift to cmd+p

This feature will finally be available in version 2017.3!
As of now you can only search the path while using / - so for example if you have a file in app/http/controller/somecontroller.php you can search it via ttp/lle/con.
BUT: The feature has been implemented in the new build, which is already available in an Early Access Programm
(see https://blog.jetbrains.com/phpstorm/2017/09/phpstorm-2017-3-eap-173-2290/)

I don't know how the functionality in Sublime works exactly, but in PhpStorm you can use 3 ways of searching everywhere, as you can see here.
Cmd + O will search by class name.
Cmd + Shift + O will search by file name.
Cmd + Alt + O will search by symbol (properties, methods, etc)
If you want to search for all files with help in their path, I am pretty sure you can do a file search with Cmd + Shift + O and then type help/*.
The keys are to include the forward slash /, otherwise it will search for files containing help somewhere in their filename.
And also use the wildcard *, otherwise it will search for folder names with those characters.
Update: you can also click Shift twice, and it will allow the same kind of search, but in files, classes, symbols and even PhpStorm tools - all at a time.

Related

Find longest file in the project IntelliJ IDEA

Hello I want to know any trick or shortcut by which one can know which is the longest file in project.
i.e which file has the longest lines of code.Is there any shortcut or plugin available?
I believe the OP was asking about the length of file, not the length of single line. You can try with such iteration:
(.*\n){100,}
(.*\n){1000,}
(.*\n){10000,}
Although this is kind of hacky it still works.
You can search your whole project using the regex repetition pattern. Just right-click your project folder in the project structure view and choose "Find in path...". Be sure to check "Regex" in the search window that appears.
So you'll start out and match any line with any length in your project
^.$
(If you're not familiar with regex: ^ and $ are used to denote the beginning and end of a line and . matches any character)
Then you gradually increase the number of matched repetitions
^.{1,}$
^.{10,}$
^.{100,}$
^.{1000,}$
(You use {start, end} to indicate to interval of repetitions. If you leave end blank it will match anything from start)
Using this you will soon be left with the longest line(s) in your project.
As I said it's kinda hacky but it's also quick and works if you don't have to automate the task.
Hope this helps you!

Intellij: how to convert indents for all files

I know how to convert indent for a single file. I go to edit -> convert indent -> space/tab.
But I want to do this for all files under a directory.
I try click on a directory and then go to edit -> convert indent, but the options are grayed out.
You can use the shortcut Ctrl+ALT+L (Windows/Linux) or ⌥⌘+L (MAC OS X) and select the Rearrange entries option to reformat the code in the current file or reformat a module or directory.
You can also Right-click a module, file, or directory from the context menu and select Reformat Code and also select the Rearrange entries option.
This will convert the indents for all files/directories selected:
This works on most of the Jetbrains IDES (iDea, PyCharm, WebStorm, RubyMine, and so on.)
It seems there is no such dedicated option in IntelliJ, but you could just work around it using a "low-level" Replace All action.
Open the Edit → Find → Replace in Files... dialog
In case you want to convert spaces to tabs, you should
Enter in the Find field (i.e. four spaces (or whatever number of spaces the project is currently indented with))
Press the Regex search modifier (Alt + X)
Enter \t in the Replace field
NB: In case you have valid strings with 4+ spaces in them, they will get replaced too. In most use cases, however, this is not happening.
In case you want to convert tabs to spaces, you should do the same as above, but swap the Find and Replace field contents
NB: Again, if you have valid strings with tabs in them, they will get replaced too. I haven't had this use case, because I've only needed to convert in the opposite direction.
You will probably also want to set a File mask in order not to replace spaces in code-irrelevant files

What is the meaning of the file names flanked by the '#' sign and how can I remove them?

When I do the 'ls' command in the terminal on my Raspberry Pi 2, I see different types of names of files, some like "#example.cpp#", as well as others like "homework1.cpp~".
What do these two file types mean, and how can I get rid of them? Simply using the 'rm' command doesn't seem to be working for me. Thanks!
Some applications will create a copy of a file and use special characters when creating the filename for the copy. For instance some text editors will make a copy of a file you are starting to edit by using the same name and adding a tilde character (~) to the end of the file. That way you will have a backup of the file that you are about to edit.
Another reason would be if an application is processing the file into a temporary file with the temporary file then being used for the next step. For example perhaps the C/C++ compiler is reading the file homework1.cpp with the C Preprocessor to generate the temporary file #homework1.cpp# which is then compiled by the compiler to generate the object code file.
I am not familiar with raspberry pi so am not sure as to what may be creating the filenames with the pound sign (#) on the front and back. Perhaps it is the C++ compiler. I am pretty sure the files with the tilde character on appended to the end of the file name is a back file from vi or vim containing a copy of the file at the time it was last opened with the text editor.
One thing that you could do is to look in those files to see what is there using a Linux command or a text editor. If you use a text editor I would copy the file to another folder as a back up and then look at it there.
Edit: Someone just posted and then deleted an answer which also mentioned about how to remove these files.
What I read was that the rm command is used however for some kinds of special characters you will need to use quotes around the name and you may also need to use an escape to escape certain special characters.
The command shell reads the command line you type in and makes changes to the text before passing it on to the command you type in. So if the filename has a space in it, say jj Johny then when you remove the file you have to specify rm "jj Johny" since spaces are used by the command processor to separate out arguments.
The other poster mentioned that you had to escape out the pound sign (#) using the back slash character in order to prevent it from being modified by the command processor.

Intellij - Reformat Code - Insert whitespace between // and the comment-text?

I am working with another human being on project from that the professor expects to have uniform code-style. We have written large separate junks of code on our own, in which one has written single line comments without a white-space between the single-line-comment-token and the other one has inserted a white-space. We are working with IntelliJ and have failed to find an option to enable the Reformat Code function, to insert a white-space.
TLDR:
Can you tell us how to convert comments from that to this in IntelliJ?
// This is a load bearing comment - don't dare to remove it
//This is a load bearing comment - don't dare to remove it!
You can do a global search and replace (ctrl-shift-r on windows with default keyboard layout, or Replace in Path under the Edit/Find menu).
Check the regular expression option and enter //(\S.*) as the text to find and // $1 as the replacement. Check the whole project option, and clear any file masks. You can single step through the replacements, or simply hit the All Files option.

Format TSQL onto one line

Our company uses an old app which reads TSQL from a .INI file. Due to how the app process the INI file the TSQL has to be all on one line. I use Poor Mans TSQL Formatter to get everything nice and tidy for things like SPs, but am wondering if there's something out there to do the reverse - take nicely formatted TSQL and shove it all onto one line (removing carriage returns , line breaks etc).
I'm working in SSMS but also use Notepad++, and will happily use some other editor if it has the functionality.
Using Notepad++ (Without any plugin)
After lot's of googling I found that there are no plugins like TextFX and PoorMansTSqlFormatter are available in x64 bit version of notepad++ even not needed.
Notepad++ --> Write Query --> Edit --> Blank Options --> Remove Unnecessary Blank and EOL.
That's it.
Using Notepad++
Select the statement that is over multiple lines then on the menu: TextFX>TextFX Edit>Unwrap Text
And for even greater ease you can assign it to a keyboard shortcut using the shortcut mapper (Settings>Shortcut Mapper)
You can use the minify comment to remove all the unnecessary space in the Poor Mans TSQL Formatter
[minify]
[/minify]
I like Martin's answer and that is probably the way to go. But I'll point out that you can just use string manipulation to turn carriage returns and line feeds into spaces. This is particularly easy in the later versions of SSMS that enable limted use of regex in the find/replace dialog.
In SQL Server 2012:
Highlight the selected text and use 'Find and Replace' (ctrl + h)
Check: use Regular Expressions
Find: \n
Replace with: LEAVE BLANK