I actually ignored the git integration that IntelliJ has and I was recently frustrated with the diff tools that git comes with by default, I noticed how intellij has a very nice way of seeing the history for a given file, and comparing previous versions etc.
What are some cool/useful git integration tips and tricks you like with IntelliJ?
I would like to see some keyboard shortcuts, like if I am on a file, I want to quicky open up the history view or compare with the last commigted file.
Is it possible to compare commits? (not just a single file)
BTW, what diff tool does IntelliJ use by default, it's pretty good!
You can view IntelliJ IDEA's default keymap reference card to see what's available starting out.
I don't believe there is a default keyboard shortcut assigned to showing the current file history, but you can specifically assign a shortcut to show file history:
Settings → Keymap → (in the search box on the right type: "history" to narrow the options) → assign your desired keyboard shortcut to "Git: Show History"
While it is definitely possible to compare various revisions of a file from different commits, I'm not sure what else you would want to do to compare commits beyond the scope of a single file, but when reviewing commits, you can view all of the changes in the commit, showing all the diffs, one file at a time.
As far as their diff tool is concerned, I believe it was internally developed and is part of their version control featureset.
Related
So I wanted to try out converting our backend API source code which is written in Java and see how it looks (IIRC there is a preview before converting), but once I did it it automatically started converting all the files in the selected folders, and in the end it asked for code corrections, which I responded with no as I wanted to cancel it and now I am stuck with a broken code base with no other options than:
Reverting to the last git commit and reimplementing all the changes done from my side (I could have prevented it but committing before the conversion but oh well)
Continue using Kotlin to code in but I have code errors which I don't know how to fix
What I am asking instead is if there's anyway to convert Kotlin back to Java in IntelliJ IDEA? Thank you in advance
Intellij has a feature called Local History and it can be used to go back in time for things you did not commit to your source control system. This history is retained until you install a new version of IntelliJ IDEA or invalidate caches. Read more in the Intellij help for the feature.
Your source code constantly changes as you edit, test, or compile. Any version control system tracks the differences between the committed versions, but the local changes between commits pass unnoticed. Local History is your personal version control system that tracks changes to your source code on your computer and enables you to compare versions and roll changes back, if necessary. Local History is always at your disposal, no steps are required to enable it.
Local History is independent of external version control systems and works with the directories of your project even when they are not under any VCS control. It applies to any structural artifacts: a project, a directory or package, a file, a class, class members, tags, or selected fragment of text.
for a mistake i've made eclipse v. 3.4.2 formatting my sourcecode on a single class file.
That's really confusing, how can i restore my own original text format?
The simplest approach is probably to use Eclipse's Local History. On the context menu for the file, select "Restore from local history." If it's not in the local history, you may need to go back to the previous version in source control... (I assume you're using source control. If you're not, I strongly urge you to do so, right away.)
Of course, another option if you've still got the file open is just to press Ctrl-Z to undo actions - keep doing that until the formatting goes away :)
I have been wracking my brain trying to figure this out. For the first time I used jEdit the other day and I was pleasantly surprised that it auto indented my code (meaning that I'd put in the following code:
int method () {
_ //<-- and it put me here automatically
I've tried to get the same thing working with eclipse but with no success. I got into the code formatter but I don't see how to make that happen.
Is it possible to do this? Also while I'm here, is there a such thing as a eclipse plugin that will allow you to search the methods and classes of the standard java library?
Thanks
Personally all I use for this is the format options Window->preferences under Java->Code Style ->Formatter.
I once took the time to tweek how I like my code to look like when I work and exported the whole thing. After that I just code without too much bother on what it looks like. When I find the code looks messy by pressing the combination ctrl+shift+f and the whole class becomes pretty again, comments and all.
After a while it pretty much became a reflex...
code code code
ctrl-s, ctrl-b (cause I disable auto build sometimes), ctrl-shift-f
code some more etc...
Once I got used to this I never really cared how it presented the code as i was typing because I knew it would look all pretty as soon as the loop/if/switch/method etc is finished
My clean eclipse install does this by default.
Have you changed any options? Make sure the file you are editing has the .java file extension. The preference options that control the typing automations are under Java -> Editor -> Typing in the Window -> Preferences menu.
Also, I find that the auto-indenting, and most of the other auto-complete functions of eclipse do not function well if the file I am editing has errors in it which prevent compilation. Make sure that your curly-braces are matched correctly, this is the main one that I've noticed blocks auto-indent.
Regarding searching through the standard Java libraries, use the Search -> Java.. menu option, and check the JRE libraries checkbox, then search away. You can also use the Hierarchy view to see how the classes relate. Also, in the Package and Project views you can expand the JRE System Library, and then expand rt.jar which holds pretty much all the standard Java pacakges.
Eclipse has always done this for me by default.
One really cool thing about eclipse is that you can search preference pages. Just right click and go to prefrences. Go to the "Window" menu, and click "Prefrences". Then at the top of the tree view there's a text box that says "type filter text". Replace that with "indent" and it should bring up the page where the indent option is.
Make sure that eclipse recognizes your file as a java file, that you're using the Java distribution, the latest version, etc.
Iv been trying to work around the eclipse indenting and other supposed features for years, and it seems that the bottom line is this ...
It only works for the programming style of the authors, so to use it you need to modify your style to comply.
This would be OK except that the authors of eclipse have some very strange ideas about common shortcut keys.
One horrid example is the search features, eg when did Ctrl+K become "Find Next occurrence" and why doesnt F3 or n work?
That all being said I use eclipse because if you have the time to wait around while it starts up - or never close it - and you can modify everything youve learned about using an editor - why why why - then it will certainly increase your efficiency.
Please note that there is a preference setting for indenting, it can be set for a project, a workspace, or globally, but no matter how you set it eclipse will still chuck tab characters in where you dont want them.
In fact its indent crazy, like it wants to indent everything, even if its already indented.
Like I said Iv been using it for years and it STILL drives me nuts with its random behavior.
Follow these steps for Eclipse:
Select all text: ctrl+A
Correct indentation: ctrl+I
You should check:
Hidden features/tricks for Eclipse?
What is your favorite hot-key in Eclipse?
I just started using eclipse for some personal projects and am finding the transition from IntelliJ (what I use at work) kind of annoying. I hope it's kosher to ask a few different questions in the same thread. Here goes:
1) How do I get "views" (I'm not sure if this is the term. I mean windows such as Project Explorer, Servers, Console, etc) to stay expanded and on top even after I've clicked back on the editor or another view. I'm pretty sure that right now all of these tabs are "quick views" that I have minimized and then docked, so I may not be doing this right to begin with. In IntelliJ, I would simply just pin the tab.
2) How can I open a file (for instance, an ant build.xml) without having to make it part of an eclipse project? I want the syntax highlighting and Ctrl-click ability that the IDE will give me (not to mention being able to use eclipse's built-in ant), but I don't need to associate the file with any others and so don't see the point of having to make it a part of a project.
3) Is it just me (wouldn't be surprised) or does eclipse have a bug with parsing empty html tags within the body of html tags of the same type. I've only tested this in a JSP, and it doesn't happen with JSF tags. For example: <div id="foo"><div id="bar"/></div>. Eclipse will give a warning saying the first div tag has no end tag. This is with the most recent version of eclipse for Java EE, no plugins have been installed.
4) Finally, a general question: Any best practices or resources to look at for organizing the eclipse interface and perspectives/views? What about workspaces/projects? Is there some tutorial out there that would be really informative that I could read through in less than an hour?
I appreciate any answers and tips/tricks.
First of all, please acknowledge that there are different people in the world and there are people who don't work the "Eclipse way". Even if I was paid for it (and I am), I couldn't work with IDEA. So if Eclipse rubs you the wrong way, it may not be for you. That out of the way, your answers:
In Eclipse, you open a view and let it stay where it is. In IDEA, the view changes all the time, things pop up and go away. Eclipse is static unless you specifically move things around. There are two ways to move things: You can minimize a part (a part is something which contains tabbed views). This moves the part into the closest border. Or you can maximize the current part (Ctrl-M). This pushes all other parts out of the way. Another Ctrl-M will restore the view.
This is a good place to show the difference between IDEA and Eclipse. IDEA tries to anticipate what you're doing and to be helpful. For me, this means it always gets in my way. It will start to format source as I type, things move, etc. That freaks me out. Eclipse is like a toolbox. Everything is there but you have to pick it up. A toolbox doesn't move on its own accord and it doesn't try to be smart.
Eclipse is based on the idea of a workspace. The workspace is the universe and nothing outside exists. If you need to go outside, you must first create a file or folder. In the "New File/Folder" wizard, you can open the advanced options (at the bottom) and link this resource to a real file/folder in the file system. May sound like a lot of effort but it allows Eclipse to display virtually anything in the explorer since it just shows "resources" in there, not actually files.
Smells like a bug. Please report it at https://bugs.eclipse.org/bugs/
I'm not aware of anything.
[EDIT] 3. As cletus pointed out, is not valid HTML. So that might cause the warning.
An Eclipse Perspective is a collection Views and their position. You can customize or create new perspectives, but the existing ones are good enough for a start (Java, J2EE, Java Browsing etc.). I recommend to stick with the default layout for a while until you've managed to use the quick view feature (which, personally, i find quite annoying). On small screens, i simply like to use Ctrl-M to switch the Editor to fullscreen mode and back, without the need of minimizing single views or move them around.
Yes, you can run external build scripts as well and it's called External Tool in Eclipse. Go to Run > External Tools > External Tools Configurations. Create either a new Ant-based config or a native executable (Program). The location of the build script or executable can either be workspace-relative (Browse Workspace) or absolute on the file system (Browse File System)
I have several different processes within a single project that I work on. I am constantly opening and closing tabs(java files) in the code editor for that particular process. Each process almost always uses the same java files.
I was wondering if it is possible to save what files are opened as part of the working set so I can select what working set I want and have all the java files open that I will need to work with. Currently the working set just sets the tree to these files, but I am looking to also have it open the files I need.
I hope this makes sense...
Mylyn should be your answer here.
Mylyn is a task-focused interface for Eclipse that makes working with very large workspaces as easy as working with small ones.
Mylyn extends Eclipse with mechanisms for keeping track of the tasks that you work on.
Mylyn monitors your work activity on those tasks to identify information relevant to the task-at-hand. Mylyn monitors Eclipse and captures your interaction in a task context.
System artifacts such as files, types, methods, and fields get assigned a degree-of-interest based on how recently and frequently you interact with them.
This results in uninteresting elements being filtered from view within Eclipse, allowing you to focus in on what is important.
Following Saheed's answer, don't miss CodeKiller's comment:
You can
Activate the task to reopen all files and
Deactivate the task to close all the files.
Bookmarks (mentioned here by user1039663) is a valable alternative.
Eclipse provides multiple ways of structuring the IDE desktop:
Perspectives: Customization of the positions of open and closed views and editors. You can copy and rename existing perspectives like the Java perspective and suit them to your needs by customizing them. See the Window menu or right-click on the perspective icon in the upper right corner
Task Management Tools like Mylyn: see answer by VonC
Multiple Windows: You can open new windows and move them to your second monitor. Select Window > New Window to open a new window. Each window keeps track of its own open editors.
Multiple Instances of Eclipse: You can always use multiple workspaces and multiple instances of Eclipse. However, this is only recommended when working on different projects, as both instances would overwrite each others files when rebuilding.
Hotkeys: By using shortcuts like Ctrl-T and Alt-Left/Alt-Right and Ctrl-Q you can quickly jump to previous locations where you have edited source files. This is a great help in navigating the open workspace.
Extended VS Presentation provides capabilities to save sessions.
Unluckily, it only works with Eclipse 3.1 to 3.8:
Project page at Eclipse Marketplace
The accepted answer tells us which tool could be used but does not provide a quick and dirty explanation on how to use it.
In my case, I hadn't finished researching a large code base but I needed to save my progress so I could return to it later hence the need to save all open tabs using Mylyn.
If you already have Mylyn installed, navigate to Window -> Show View -> Task List to view the list of tasks. If you've never used it before, the list will be empty.
Right-click inside the Task List view then New -> Category to create a new category. Right-click again New -> Task to create a new task.
Double-click on the task you just created then click on the Context tab at the bottom left of the view.
Now navigate to each tab which you would like Mylyn to save by clicking on the tab name. Notice how an entry for the source file for that tab is added in Context tab of the Task List view.
Once you've cycled through all the tabs you'd like to save, you can confirm they were saved by closing each one and double-clicking the source file in the Task List to restore the tab.
I've edited this answer as per below comment (include essential parts of answer in this post).
Yes, you can save off groups of tabs in Eclipse by installing this Session Manager plug-in.
I've wanted this functionality in Eclipse as well. I recently wrote a feature and have been successfully using it for a few months now. It is a new OSGi type extension and works with Eclipse Neon and above.
Here's how to install it.
In Eclipse, go to Help → Install New Software
Click “Add”, enter a name like “Editor Sessions” and the following URL.
http://spillikinaerospace.com/eclipseInstall/
Unckeck “Group items by category” to see the feature.
Check the box that says “Editor Sessions Manager” and click Next.
Read and agree to the short license agreement.
Click the remaining install buttons.
Allow Eclipse to restart.
Full set of instructions are here: http://chrishull.com/projects/eclipse/
Please give it a try and send comments. I've found it a very useful tool as I work with several Eclipse projects at once and need to recall file groups.
Hope you enjoy it;
-Chris
In addition to all mentioned... Did you try Bookmarks? You can save multiple bookmarks into one set, there are bookmark sets management option and you can add descriptions with prefixes to group bookmarks on the same set. Finally and more important: you can select multiple bookmarks, select goto and multiple editors will be opened at once.
You need a Macro. Searching using this term at Eclipse plugin sites like eclipseplugincentral.com and so on must yield enough suggestions, for example Practically Macro. Good luck.