Creating new JS file from the selected code - webstorm

Is there a way in Webstorm to quickly create a new file from the selection?
For example, lets say I am working in product.js on a Product class and realize I also need a new Manager class. In C# via Resharper, I can write the new class right there in product.js, then select it and ask Resharper to move it to its own file. Resharper would create a new file and move the code there.
In WebStorm I need to do these steps manually:
Create new file
Write code there (or cut-paste it if I already wrote it else wrote it elsewhere)
Add a reference to my html.
Is there a way to speed up that process in Webstorm?

this option is only available for javascript embedded in HTML: Refactor/Extract/Extract Include File...

Related

Is it possible to modify the templates used during creation of a C++ class by the Unreal Editor's Class Wizard?

I am starting a new project and it will require the creation of many C++ classes. In order to keep the project organized I created coded standards that will keep methods and member variables organized using regions, nothing too complex. However, I do not want to have to modify every new class I make adding the separators(regions) by hand or have to copy paste from another file.
In unity it is possible to modify the template used in the creation of a new script, but i am having trouble finding the same information for the Unreal Engine. I am not using source and if it is required to do so I will probably just copy paste it for every class.
I tried searching online for information on the subject, but the results were less than useful.
You can modify, create, and delete templates in Unreal Engine. Since you are not using Unreal Engine source, the templates are all located in the C:\Program Files\Epic Games\UE_{version}\Templates directory. If you are using Unreal Engine source, then the location will instead be {engine-location}\Templates. In these directories, you can modify the configs, the content, and the source code of each template. And of course, you can create new templates and delete existing ones.
If you do create a new template, then make sure that you do the following steps:
Move the project that you want to make a template out of to one of the Templates folders mentioned above depending on the verison of Unreal Engine you have (source vs non-source).
Update the ProjectName variable in your template's Config\DefaultGame.ini file.
Copy any of the existing templates' Config\TemplateDefs.ini file to your template's Config folder.
Modify the copied TemplateDefs.ini file, specifically the LocalizedDisplayNames and LocalizedDescriptions variables. These are the name and description of your template that show when the template is selected while trying to make a new project in Unreal Engine. Note that you may have to modify the other parts of the TemplateDefs.ini file depending on your project/template.
Lastly, add pictures in your new template's Media folder. Add one picture named {new-template-name}.png, which will be the icon of the template and another picture named {new-template-name}_Preview.png, which will be be the preview of the template that appears alongside the name and description after one clicks on the template icon while trying to make a new project.
For more information, check out these resources:
https://docs.unrealengine.com/en-US/Engine/Basics/Projects/CreatingTemplates/index.html
https://www.youtube.com/watch?v=MYM7iSh-uac

How to add a document as a child of another document in a Roslyn project?

In Roslyn, I can add a new document to a project like this:
var documentId = DocumentId.CreateNewId(currentProject.Id);
var newSolution =
currentSolution.AddDocument(documentId, "myfile.cs", code);
Using the Visual Studio SDK, I can add a new file as a child of another file like this:
parentFileItem.ProjectItems.AddFromFile(newFilePath);
Where parentFileItem is the document - of type ProjectItem - under which I want to add the new file. And newFilePath is the path of the new file.
I want to be able to do a similar thing to a Roslyn solution. Is this possible?
If that is not possible, can I "move" an existing ProjectItem to become a child under another existing ProjectItem via the Visual Studio SDK?
That is, I will add the new document via Roslyn, and once changes are applied, I want to move the file created via Roslyn under another existing file.

Is it possible to use templates when creating a scratch file in PyCharm?

I created a custom template file and I can use it from the "File"->"New..." menu option.
But I was expecting to see it also when creating a new scratch file using
"File"->"New Scratch File"
Is this even possible?
(I am using PyCharm 2017.1.2)
I think it's not possible: each time you create a scratch file, it's created from scratch.
Though, what's possible in order to simplify your life, is using Live Templates: you can create your own abbreviation, which can be expanded automatically to some portion of code. There are many examples in Settings -> Editor -> Live Templates so you can use them as an example.

How do I turn off the auto message on a new file in Webstorm IDE?

When I create a new file in a webstorm project I get a superfluous message telling the next person 'who made the file and when'. Since the invention of source control I really don't see why jetBrains have decided to make this default anyway how do I turn it off?
This is probably because you have USER and DATE as part of your file template:
Just get rid of the the stuff in the template and you should be good to go. In other words, get rid of 3 and 4, and you will no longer be prompted.
Usually webstorm will not prompt you for this, but for some reason in the installation the username was not added to its list of macros.

BitBucket Wiki: Create a hierarchy structure?

I want to create a hierarchy in my wiki like so:
General
FooPages
Foo1
Foo2
Foo3
ODP
Bar
Baz
I would like to create these pages, and use <<toc>> table of contents macros to organize them.
How can I do that? Do I need to clone and edit the wiki on my own machine, or can I do that exclusively through the web interface?
You can (partially) do this, using <<toc / >>.
This will create a TOC for all the headers in files in the root directory.
It will not list headers in file in the sub directories, though.
You can do the same for <<toc FooPages/ >> etc.
You can do this both through the web interface and locally on your machine.
I placed some TOC examples on this Bitbucket wiki page: http://bitbucket.org/marijnvanderzee/build-wiki/wiki/TocTests. You can view the markup there.
Make sure to balance the equal signs on you headers; e.g. use == H2 == instead of == H2.
Both are valid, but at this time, the latter is not recognized by the <<toc>> macro.
Regarding the hierarchy side of this question, it's worth clarifying:
You can create a hierarchical structure by using the Title field when you create or edit a wiki page.
Eg: If you want to create a new file Bar.md inside a new Foo directory, just create a new page and in the Title field write "Foo/Bar.md". It will create the directory and the file at the same time.
I'm not sure if there's a way to just create the directory without adding a file to it straight away.
Regarding the TOC half of this question, I found that I can use the # HeaderTitle syntax in Markdown pages, and Creole's TOC macro will recognise it.