Quick inserting a relative path in PhpStorm

In PhpStorm:

Is there a fast way for inserting relative path to other file (ex. css,js, image files) in another one? (Perhaps by dragging file in code position)

Answers


Ctrl + Space + Space

Hold Ctrl and press Space twice...

Autocompletes relative path...


No, there isn't anything that I would consider "fast" but there are a few tricks that I've found to be useful.

In a large number of contexts PHPStorm will by way of it's auto-complete help you form your relative files references. For example, when typing a PHP require statement, you can use completion to get a list of files and directories in the auto-complete popup, and use that to help you navigate and create the string you want:

The auto-complete doesn't seem to always happen automatically, but you can invoke it. My keyboard shortcut is CTRL+SPACE. From the menu, it's Code -> Completion -> Basic.

You can also use the Copy Reference function available by right-clicking on the file in the Project explorer. This will put a string in your clipboard starting at the project root directory. For example, if your project is located at c:\my\project, and your file is located at c:\my\project\web\assets\js\myscript.js, the string copied will be \web\assets\js\myscript.js.

I tend to use either of these methods depending on what context my cursor is currently in, and whether or not my hand is on the mouse at that moment or not. By far the most useful feature is the auto-complete. I use it very often when creating strings to resources in both HTML and PHP files.


Need Your Help

How do you represent inheritance in LinqToSql?

linq-to-sql inheritance

I need to represent inheritance like Person/Student. How do you do that in LInqToSql?

Needing to find matches in my controller from an array! Ruby on Rails

ruby-on-rails arrays activerecord controller

I am in a broken spot. I was able to get the array from into @set1 and now need to compare @set1 with @set2 and see how many matches there are. I can get the @array1 to work correctly if I have sta...