How can I duplicate (clone) a tab in IntelliJ Idea? - java

In Eclipse I just click above the tab and click on "New Editor". In NetBeans is "Clone". In IntelliJ Idea I didn't find this option yet. What I do now is split vertically but it is not what I want.

You can't have multiple tabs for the same file without using split
mode (vertical or horizontal). If you want a copy of the file, use
Refactor | Copy.
To quickly split the view and make the same file visible in 2 splits hold Ctrl and drag the tab into the editor area.
UPDATE: feature request added, please vote.

Split Vertically
Drag second tab to another Window/Monitor

You can do this simply by Holding CTRL button and drag the tab to the empty space or another monitor.

Use Shift + F4.
Ctrl + F4 to close it.

You can drag the tab "out" of IntelliJ to create a new window with open tabs. Then reopen the file in main window.
See this video
This requires the new IntelliJ IDEA 10.

Yeah, split (vertical or horizontal) is the only option that I have found. You will find the IntelliJ support people really helpful, though, worth asking this question there: http://www.jetbrains.com/support/idea/index.html

Shift-Enter will open the file in a floating window.

Related

Is there a way to open two tabs for the same file in IDEA?

Sometimes I need to look at one piece of code already written and write another piece in the same file. When the code is too long, for beauty or other reasons, I have to write for a while and then slide to the piece of code I want to see, and then slide it back to write again. Is there any good way to avoid this trouble?
thanks a lot
You don't have to use a mouse to do it! Remember everything in IDEA is configurable so my keyboard shortcuts may not work for you though you can configure them in the keymap.
There are two ways which you can open multiple files in IDEA:
The first method would be to split the editor:
search by action cmd shift A on mac
type split and choose how you'd like to split
The second method would be to open the file in a new flowable window:
Select on a file in the project window
Use shortcut shift f4 or search by action cmd shift A on mac
Type open source in new window and hit enter
right click into tab name, and select split vertically or horizontally
if you are using git. then find "local changes". it will compare your current changes with the origin
https://www.jetbrains.com/help/idea/viewing-changes-information.html#comparing_local_changes
In Android Studio I see "Split Vertically/Horizontally" options when I right-click on the tab name which do exactly what you want. Since AS is derived from IDEA the functionality might be there too.
If you use JetBrains IDEA, the form can be split vertically by right-clicking
If you use Eclipse, you can ctrl + shift + [

Compare sources in eclipse

Very often I encounter situation where I need to see or manually compare two eclipse sources. It can be a situation when I extending some class and looking at current implementation of superclass and writing similar implementation in subclass. Here are solutions come in mind with time:
Just copy prototype class in another file and edit it in place with commenting/uncommenting. This solution seems a bit dirty to me and causes hidden "copy-paste" bugs.
Open prototype class in another editor and make it "always visible". It's a tricky.
Have state where prototype and actual classes accesed sequentially, so we can using Back-Forward hotkeys ALT+LEFT and ALT+RIGHT to switch between them, but the problem left - we have only one active screen at time.
Is there a more clever way to get functionality that I need?
I think that #Nos explains the more accurate solution, but if you need to have two active editors at the same time... You only need to open the both files, and then "detach" one of the tabs, or move it to another editor.
To move a tab to other editor window, you only need to click on the tab title and drag it to another position. It will automatically created another editor window.
you can click on source file tab and right click-> then select new editor. you will get duplicate tab there. after that click on that and drag to any direction and you will get two different frames for file
I am not sure what version of Eclipse you are using but in general you just select the two files (using the ctrl-key + mouse) you wish to compare, then right click on one of the selected files, go to "Compare with" sub-menu and select 'Each Other'?

Next / Last Edited Position Eclipse Shortcut - And Netbeans?

I remember in Eclipse there were buttons in the toolbar that took you to the last edited position in a document.
This was great cause you could write some code, click on a method to go check out the code there, and then click "back" to get back to where you were coding.
Any idea if this can be done in Netbeans?
Certainly, it's unbound by default but you find the setting in Tools -> Options -> KeyMap. Search for last for instance to find the setting.

How to show two or more editors at the same time?

Eclipse allows to show more than one code editor at the same time... so you can have something like this:
Can I do something like that using IntelliJ Idea?
There are two ways to do it:
Click the tab header, then split vertically/horizontally. (works prior to IDEA 10).
Just click the tab header and holding left mouse button move the tab out of the window (separate editor will open). (IDEA 10). (See Detachable tab editors section on the features page.)
When using the second option I find that global history (CTRL+ALT+arrows) is spammed. See bug IDEA-64656 Navigation (Back & Forward) works incorrectly in the case of splitted editors and it is finally fixed in the 103.190 EAP build
Right click on a tab with file name and select 'Split Vertically'/'Split horizontally'

Does NetBeans have any "collapse all" shortcut for open directories in the navigator view?

NetBeans has a helpful (to me anyway!) feature under the "Views" menu, called "Synchronize Editor with Views". As the name suggests, toggling this on will cause the navigator view to jump straight to a file when it's opened in the editor.
I generally prefer this to the normal "Ctrl+Shift+1" shortcut for manually jumping to a file. However, the downside is that after editing several files, your navigator tree is a mess of multiple open directories.
Eclipse has similar functionality, but it also has a "collapse all" button at the top of its navigator view... restoring things with a single click having to scroll around. Does NetBeans have any similar mechanism for collapsing open directories? Maybe a poorly-documented keyboard shortcut buried in there or something?
Unrelated to your question, but some interesting code folding shortcuts are:
Action
Shortcut
Collapse Fold
Ctrl+Minus
Expand Fold
Ctrl+Plus
Collapse All Folds
Ctrl+Shift+Minus
Expand All Folds
Ctrl+Shift+Plus
Unfortunately, after further digging on the NetBeans discussion forums and mailing lists, it seems that this functionality simply doesn't exist. That's a shame... hopefully they'll add it in the future.
Answer: It is not possible.
Workaround: Close the project and reopen it. It will start collapsed.
Close the navigator (press the x). Then go to Window->Navigating->Navigator or press Ctrl+7. It should open the navigator with all collapsed.
http://variousfixes.wordpress.com/2011/09/03/how-to-collapse-all-elements-in-netbeans-navigator/

Categories