IntelliJ IDEA - New Template - intellij-idea

I'm trying to create a set of custom file templates for IntelliJ.
I basically want to go right-click, "New > My File Template" similar to the "New > Java Class" bundled with IntelliJ.
I've added my own custom file template via "Settings > File Templates", but they don't appear in my "New" context menu.
This is a Java project, and my templates extension is java. Am I missing something?
All help greatly appreciated.
No My Template >>>

If you select Java Class you can then choose the template for your new class. This is a new feature, it used to be available when selecting New.

Actually you can, sort of.
I don't know know how to do it for Java files. but
if you set the extension to txt you it will show up in the right click menu.
and here it is in the menu:
the only issue is if you're creating a java class you'll have to rename the file after creation to ${name}.java

Related

How to show class file in explorer in idea

How to show class file (not java file) in explorer in IDEA?
When I select a java file, I want to position it in the explorer, I know in Eclipse it is easy, but what I should do in IDEA?
You can do it with the External Tool like this:
This answer describes what parameters to use for the explorer.exe to select the file.
Using IntelliJ IDEA macros the Arguments field will look like this:
/select,"$OutputPath$\$FileDirRelativeToSourcepath$\$FileNameWithoutExtension$.class"
It will open Explorer with the output file selected:
For the source file located in C:\work\attaches\hotswap-bug\src\foo\bazz\Another.java the tool will select C:\work\attaches\hotswap-bug\out\production\hotswap-bug\foo\bazz\Another.class file.
This tool can be invoked from the editor right click menu while inside the source .java file:
You can also assign a keyboard shortcut to this tool or make an action in the toolbar for easier access.
Final result:
Just curious, what's the real world use case for this?

How can I make qtcreator change the Project view when I open a new cpp file

There is this feature that IDEA IntelliJ has: when a new file is opened the Project tree (view) automatically jump to the file opened (handy when you follow a function defined in some other file).
I'd like to know if qtcreator provide this option
Surprised how hard it is to find the answer, since the button isn't hugely obvious.
The button you want is at the top of the Project pane, between "filter" and "split". Tooltip says "synchronize with editor".

IntelliJ file new move Java Class on top

When I do a file new in my IntelliJ idea. I see a menu like this one
I want to see classes from Java and Scala on the top. I don't want to uninstall plugins for ruby etc. But these should not be on the top. I mostly code in java and scala and therefore want these classes to be one top.
When I want to create a new Java class, I activate the "Project" view. Then I select the package to which the new class shall belong to. Then press Alt+Insert. This popup menu is shown:
Please ensure that the directory you're creating a class in is under a module source root. You can navigate to it in Project View, right-click on it or any its parent and choose Mark As... | Source Root

Using file templates in IntelliJ

I'm quite confused when it comes to file templates in IntelliJ. Basically, when I right click anything and hover my mouse over to New, I can see the usual file templates like Java Class, HTML File and so on. I downloaded Scala plugin and I can see Scala templates (Scala Class, Scala Object, etc.) if I go to Edit File Templates, but I can't actually use/see them in the New menu. Is there a way to modify what I see in the New menu? I'd like to be able to create Scala classes.
Go to Settings -> Menus and Toolbars
There you will see many type of menus. You need edit the menu you want the files to be displayed. Most Probably "Project View Popup Menu".
Click on "Add After" button on right. There you choose the file form plug-ins or other category to be displayed.
I added "Show Bytecode" to meny well it does not make sense here. You can add files from scala plugin like that.
You can restore to Defaults if you mess up easily by clicking on
"Restore All Defaults" button.

View Source on File Double-Click?

I added Foo.scala as a new Scala class within my IntelliJ 14.1 project:
class Foo
object Foo
When I click on this file once in IntelliJ, it expands the Class and Object:
I find it to be a hassle to have to click the file (Foo.scala), and then double-click the Object/Class to view the source.
How can I configure IntelliJ to open the source file once I double-click on the file name, i.e. Foo.scala per this example?
You can't. Please file an issue at JetBrains if you want to have this improved.