"E325: ATTENTION, Found a swap file by the name file.c..." I just can't take it anymore! I'm switching to Eclipse. I'll still use vim for all my small editing tasks but, in projects with 200+ files, vim just feels poor.

Getting Started

Explain the difference between workspace, IDE, view, perspective, and editor.

Download site: http://download.eclipse.org/eclipse/downloads/ Personally I'm using 3.3M6 but it's a little less stable than the 3.2 stable release (update: now using 3.3 final, works great). Then install these plugins:

TODO: I no longer see a need for goto file... control-shift-r works just about as well.

You can use Customize Perspective and Save Perspective As to create your own perspectives. However, this functionality is pretty limited at the moment; pretty much you can only do minor tweaks to the menubar and toolbars. I wish it could hide all editors except for a certain type.

First of all, keep an entirely different Eclipse runtime environment for each major task you want to do. For instance, I develop both C code using CDT and Rails websites using RadRails. In theory, I could just stuff all the associated plugins into a single instance of Eclipse and do everything in the same environment. In practice, this tends to discover all the integration bugs possible. It's just unmanageable. So, I have two environments: the C environment, and the Web environment.

CDT: a Working Set is just a group of related CDT projects. This allows you to search them all, build them all at once, etc rather than having to visit each one manually. Think of it as a subset of the projects in your workspaces.

TOBLOG:

CDT has a really weird schizm that took me a while for me to figure out. CDT has two different types of project:

  • Managed, where CDT launches the build tools itself based on the project settings.
  • Unmanaged, where you include a Makefile and CDT works by invoking make and parsing the output.

If you have a Managed project, the Build Configurations menu items will be active and the Make Target menu items will be grayed out. If you have an unmanaged project, the reverse will be true.

I don't quite understand the exclusivity... Why not treat Make Targets as Build Configurations? That way you could have a managed project that maintains the main build itself but includes a Makefile to create an oddball configuration.

Managed would turn into a project that doesn't include a Makefile. Unmanaged would be the exact same project but with automatic builds turned off. A Build Configuration would be exactly the same as it is today, except that the Tool Settings dialog would let you specify EITHER the individual tools settings OR a command line to launch. If the user specifies "make -k all" in the command line then it's just like having an unmanaged project today.

That makes the UI much easier because then you just have standard Eclipse configurations, no matter how the project is actually being built. Get rid of the oddball Make Target menu items and views.

Those inexplicably gray menu items cost me a few hours! When it's gray, how on earth can I figure out how to make it active again?

And why on earth is the Make Targets menu item grayed out when I'm editing a C/C++ file that is a part of that make target? It seems like if I have a project or one of its files selected in the navigator, or I'm editing one of its files, then Make Targets should be enabled.

Code Completion:

I was having real problems getting the code completion to work. Then I stumbled across this:

http://72.14.203.104/search?q=cache:5RKpkTROFY4J:cdt.eclipse.org/docs/EclipseCon.ppt+cdt+discovery+profile

 Change Discovery Options
   Discovery profile to 'GCC per flie scanner info profile'
   Provides better build information for the indexer

sic. :) That works SO much better! How come projects don't come this way by default?

PermGen Crash

The Sun JVM has a design flaw. It only allocates 64 MB for so-called PermGen space. (actually, the design flaw is that the permgen distinction exists at all). An Eclipse IDE with a few plugins will exhaust this easily, and will just hang or crash at random times. It's really frustrating.

  java.lang.OutOfMemoryError: PermGen space

The fix: don't use Sun's JVM. No other JVM exhibits this instability.

The workaround: put this into your eclipse.ini:

   -XX:MaxPermSize=128m

More on the eclipse wiki.

Necessary Extensions

  • Either subclipse or subversive. They are about equal in functionality. At this point I'd suggest Subclipse because it's more stable and Subersive's extra features are not really more compelling. Hopefully this confusion shakes out in the next couple months and the Eclipse project chooses the better of the two to include (my money's riding on Subclipse). The one problem with Subclipse is that its navigator view is just horrifyingly ugly. How about just a revision number please? Or something like "2 days ago by bronson" in super light gray?
  • GotoFile. I like it a lot more than Control-Shift-R Open Resource.
  • The vi plugin editor. It's worth the $20. My fingers are just too used to vi keybindings.
  • RadRails/RDT if you're going to be doing Rails development.
  • CDT if you're going to be doing C/C++ development
  • If you're using CDT, I suggest plugging in a code formatter. http://astyleclipse.sourceforge.net/ seems to be a good one. (this is obsolete! CDT 4.0 has its own internal code formatter. Hallelujah!)
  • If you want to use CDT on an automake'd project (ick), make sure to see the CDT autotools, intro.
  • TODO: play with the changelog generator, http://sourceware.org/eclipse/changelog/
  • You might want a regular expression assistant, especially if cranking Rails code. Daniel Spiewak recommends QuickREx.
  • For editing XML files, xmlbuddy comes highly recommended: http://www.eclipse-blog.org/xml/xmlbuddy-for-eclipse.html I couldn't find anything that looked decent for XSL editing/debugging.

Color Schemes

Whether you like light-on-dark or dark-on-light, you're probably going to hate Eclipse's 100% white burn-me-in-the-eye background.

How do I fix this? http://www.eclipsezone.com/eclipse/forums/m91973737.html In other words, it gets it from the OS. That sucks. I spend WAY more time in Eclipse than any other program on my computer... it's not surprising that I would want it to have a different color scheme.

And, if you like light-on-dark, Eclipse won't make you happy. https://bugs.eclipse.org/bugs/show_bug.cgi?id=41867 This sort of bug has been languishing in the Eclipse project for years. Aptana has completely replaced Eclipse's color schemes with its own much better mechanism but there's little chance of that ever going upstream. Alas, it would appear that Eclipse will remain ugly for many years to come...

Subclipse

It appears that there's no way from within subclipse to switch a repository from one URL to another. For instance, I accidentally checked out my repo using the anonymous url svn://repo. After I had made a bunch of changes I discovered that I needed to have actually checked out https://repo.

On 1 Dec 2005:

Add support for relocating repositories. Right-click on a Repository location adds a Relocate option that allows you to change the URL of the repository. It then updates all projects linked to that location by running the svn switch --relocate command.

I can't find this anywhere! Does it still exist? I figured detaching and reattaching should produce the same result, but there's no way to specify reattaching to a different directory.

Luckily it worked just fine from the command line: "svn switch --replace svn://repo https://repo".

Vi Plugin

I wish "gv" would bring back the previous selection.

I wish == would reformat just the current line (= works with selection or direction key too, =G).

I wish the incremental search would open a fold if it's closed, then return the fold to its previous state if the user continues searching and exits the fold. If the user stops the search inside the fold, it should just be left open until the user closes it again. How does Java's incremental search handle this?

Control-Left is basically the same as vim's Control-T. And Control-F3 is the same as Vim's Control-].

Vi Plugin's Control-T is redundant, >> and << work fine. So make sure to disable it in Window -> Preferences -> General -> Keys -> Modify so that you can use Eclipse's type hierarchy navigator. Vim's Control-T is unnecessary too since Alt-LeftArrow does a better job anyway.

It looks like Control-Shift-U should do something in Eclipse but the Vi plugin is wrecking it somehow...?

Unfortunately Control-V (rectangular selection) isn't supported by Eclipse. It's proposed for a future version; I'm sure when they ship it will be added. Until then, v and Shift-V work fine.

Hitting : when text is selected automatically constrains the : command to the current selection, even though \<,\> doesn't get automatically inserted like in Vim.

I hit "restore defaults" in the keybindings preferences and my Vi keybindings all got blown away. I'm not too bummed about this because -- other than ^F and ^B (which I'll just get in the habit of using PgUp and PgDn), I never used em anyway.

New Projects

You should set all files in a new project to UTF8: http://www.eclipsezone.com/eclipse/forums/t93442.rhtml. Old projects are a bit of a problem. Hope they're using your OS's native encoding!

CDT Indexing

The CDT indexer sometimes falls apart. The biggest culprit is not setting include paths that your project uses. And the second biggest culprit is indexer bugs.

To rebuild the index, right click on the project and choose Index -> Rebuild or Index -> Freshen All Files (I'm not sure what the difference is).

CDT Tricks

Preferences

  • Turn on "Ensure newline at end of file" in Window -> Preferences -> C/C++ -> Editor.
  • Turn on "Save automatically before build" in Window -> Preferences -> General -> Workspace.
  • Turn on "Editor Problem Annotations" in Preferences->C/C++->Editor->Hovers->Enable Editor problem annotation. This allows you to see where the indexer is falling down (and CDT 4.0's indexer is weak enough that it will certainly fall down on just about any nontrivial project).

Navigation

  • Jump to declaration under cursor: Control-Click or F3.
  • Jump to definition under cursor: Control-F3
  • Type identifier to jump to:
  • Enter the type to find: Control-Shift-T. (does it accept abbreviations?)
  • Go back: alt-left-arrow. Go forward is, of course, alt-right-arrow.
  • Jump to last edit: control-Q
  • Jump to next/previous function: Control-Shift-Up, Control-Shift-Down
  • Open a resource: Control-Alt-N. Control-Alt-R is Eclipse's built-in, but it's not as good as GotoFile.
  • Quickly jump to other open files: Control-PageUp, Control-PageDown, Control-F6
  • Show Outline (quickly jump to other methods in class): Control-O
  • Show a quick list of open files: Control-E
  • If you're seeing navigation problems, the first thing you should do is enable "Editor problem annotations" in the preferences (C/C++ > Editor > Hovers). Generally this will show you why Eclipse can't figure out the right completions or call hierarchy.

Searching: Select some text and then...

  • Find Declarations: Control-G
  • Find References: Shift-Control-G
  • Find all occurrences in workspace (like grep): Control-Alt-G
  • Jump to the Next/Previous find: Control-, and Control-.

Editing

  • Move current line or selection up or down: Alt-Up, Alt-Down
  • Copy current line/sel up or down: Control-Alt-Up, Control-Alt-Down
  • Toggle comment: normal: control-/ block: control-shift-/
  • Remove block comment: Control-Shift-\
  • Reformat current line or selection: Control-Shift-F. Note that CDT doesn't come with a formatter, see Necessary Extensions above.
  • Toggle quickdiff (showing changes in left bar): control-shift-Q
  • Add an include file: Control-Shift-N (doesn't work for me??) Nope. I've seen it work once for printf. And then I saw it add "curdir.h" instead of <error.h> TO curdir.h! It's a complete cock-up.
  • Scroll the window without moving the cursor: Control-Down, Control-Up
  • Complete Word: Alt-/
  • Join lines, like in vi: Control-Alt-J

Building

  • To build the project (last config?): Control-B

Windows

  • You can tile editors by dragging one of their tabs out of the work area. (but is there a keyboard command to switch between tiled editors??)
  • Open or close a fold: Control-Keypad+ Control-Keypad-
  • Close all folds: Control-Keypad-/

Debugging

  • Move the cursor to a line and hit Control-R to run to that line. Use it to move past a long loop while single stepping.

Other

  • Focus the editor window: F12 (useful when a keystroke has focused another pane and want to go back to editing).
  • show available keyboard shortcuts: Control-Shift-L
  • To show gdb traffic while debugging, turn on "Verbose Console Output" in the launch configuration (on the Debugger tab for the gdb/mi debugger). This can help when the debugger is doing something strange.

For the keyboard junkie

  • Switch to next editor/perspective/view: ^F6/^F7^F8. Hold shift to move previous. Control-F8 is most useful to bounce between two perspectives.

I use vi's incremental searching because it's way better than Eclipse's built-in stuff.

To see what changes you've made that Subclipse is tracking, hit up the Team -> Synchronize context menu. It does look a little buggy though: it claims some files that I have added and not committed yet are not added. At least the commit itself gets it right.

  • Smart Insert Mode in the Edit menu is similar to set nopaste in vim. Smart insert mode causes Eclipse to reformat what you enter, turn it off and Eclipse will take your input verbatim.

CDT Wishlist

  • Isn't there anything to help keep .h and .c files in sync? Apparently not; refactoring tools come later?
  • Control-T: quickly jump from parent to descendant classes
  • How do I quickly jump between declaration and definition? Is there a RadRails-like control-shift-V alternative for CDT? This isn't quite like F3 because F3 only operates on what's under the cursor... This feature would work no matter where you are in the function. For CDT 4.0 (due June 2007) I guess F3 is what it must be. If there were a .h/.c synchronizer, the need for this would mostly go away.
  • Is there an easy way to view the preprocessor output?
  • Why won't F2 show me a brief description of the identifier under the cursor?
  • Is there any way to show only the .c, only the .h, etc files in the Navigator?
  • Also, can I view them alphabetically so that .c and .h are side-by-side, rather than by type? The docs claim that the C/C++ Projects menu includes a Sort item... I sure don't see it in my Eclipse!
  • Why isn't CDT parsing as I type? It should show me syntax errors and let me navigate even in files that haven't been compiled yet, right?
  • Control-Shift-N doesn't work for me.
  • There appear to be some minor problems with the Rename refactoring (the only refactoring that exists). I'll try to reproduce this later.
  • Alt-Shift-W doesn't appear to show the selected term under the cursor.
  • Control-Shift-T allows me to type the name of a typedef to find. How can I type the name of a function or a macro?
  • I wish there were a way to read manpages directly from within the Eclipse environment. Or to somehow document built-in C/C++ APIs so I didn't have to shell out to run man all the time.
  • Why isn't CDT smarter about editing comments?
  • Should hang a lot tighter with comments. Can't we just use javadoc wholesale? Doxygen is basically JavaDoc for C/C++, why not use that?
  • Control-Alt-H: open call hierarchy for method under the cursor. This should allow navigating to all callers and callees? (the team agrees, it's on the road map for 4.0) And it should be reliable as of CDT 4M6.
  • I wish I could fold loop code, conditionals, and comments too. I also wish Eclipse made the folding a little prettier. That square with two dots in it just looks like Eclipse has Unicode issues.
  • What happens if I edit source code while debugging? It appears to suffer from the age-old GDB problem: the instruction pointer suddenly starts appearing in random places and you're thinking, wtf? It would be nice if the debugger perspective could show the correct, unedited source code while the CDT Edit perspective allows you to change things. This would be almost as nice as the Java debugger allowing you to insert new code into a running application. https://bugs.eclipse.org/bugs/show_bug.cgi?id=44541
  • Why doesn't search work in the Debug perspective? Everything I search on returns zero hits. Switching to the Edit perspective and searching again seems to work. No, I take it back. It does work. Why does search sometimes fail? Maybe it's doing a symbol search and not a full text search?
  • Why must there be only a single console. I really REALLY would like build output to go into one console, and my program's output to go into another.
  • When making a make target, I wish CDT offered feedback when it completes. ANd I wish it included a console below the make targets so there was no need to switch to a different view. That little tiny status feedback in the bottom right is OK but I wish it were a lot larger.
  • How about offering a combined memory view that looks just like every other memory viewing utility, where a column of ascii comes after a column of hex. And, I'd like to be able to choose whether the hex is grouped into byte, short, word, or longword chunks. Finally, there's no need for resizeable columns since there's a horizontal scroll bar.
  • Why doesn't it save the scroll position in the editor when I quit? When I resume, my windows open exactly as I had them except that they're all scrolled to the top.
  • Personally, I loathe automake/autoconf. But, does CDT work with it? It appears not to; I need to run configure by hand before CDT can find a makefile that it's happy with.
  • DBG: Why can't I click on a function pointer variable and have it show me the routine it points to? GDB does provide this info. I wish CDT would use it.
  • DBG: Why can't I format a variable as a string? It's a pain in the butt to have a char* display as a hexadecimal number because then I need to actually click on it to see its value. Painful when your variables display includes a lot of strings.
  • DBG: My project includes two main.c files. When I double-click main in the stack backtrace in the debugger, Eclipse opens the wrong main.c. This is strange because GDB should tell it the correct one to open! https://bugs.eclipse.org/bugs/show_bug.cgi?id=176636
  • How do I restrict a Control-Alt-G search to a single project? Or, if it MUST search multiple projects, how do I get it to display the curren't project's results first. Right now the first project alphabetically shows its results... not very useful.
  • DBG Why do the breakpoints disappear if the source file changes? They should try to remain with the statement they were originally associated with or, if that's impossible (orig statement was deleted?), they should jump to the very next breakpointable spot in the program.

Eclipse Wishlist

  • Triple-click to select a line! It works in your type-in dialog boxes, why doesn't it work in the editor?
  • Ability to search in the same file for the current selection or the identifier under the cursor. Just like the super handy * in vi.
  • Optional focus-follows mouse for the edit panes. If I move the mouse from one pane to another, I expect the new pane to get input without needing to click. It works like that everywhere else on my system. (this appears to solve this http://divby0.blogspot.com/2007/04/focus-follows-mouse.html except that maybe it goes too far...? I'll have to play with it)
  • Also, there should be a key combo to switch between visible editors. I get the feeling Eclipse devs don't run with more than one editor open very much...
  • A color manager. Please have one dialog box in the preferences area where the user can specify every single color that Eclipse uses. It should have a global settings are, then a section where plugins can add the colors that they need. It would especially require inheritance (I want RDT to inherit the Java editor's color schemes where appropriate). Finally, I would be able to name profiles, save them, switch to them instantly, and share them with friends.
  • How about a terminal emulator so that when I do have to run man or twiddle resource files directly, I don't have to leave the Eclipse environment? It's coming?
  • Eclipse bug: if you delete a project while it's being debugged, the debugging session isn't shut down properly.
  • Why doesn't it support GTK's ability to remap menu accelerator keys? That would be super handy.
  • Shift-Control-L is nice, but I sure would appreciate putting a search box in there. It's an awful long list to scan through manually.
  • Should show shortcuts in tooltips. For instance, search history should have a keyboard shortcut that shows up in its tool tip. Also, Expand All and Collapse All should have shortcuts.
  • Isn't there a way to edit a previous search? After entering a complex query, I might like to tweak it and search again.
  • How do I search for a full word? It seems that the search box doesn't allow this?
  • The console needs to not scroll to the bottom when there's output. It makes it impossible to read parts of a make.
  • I wish the Progress view would display tasks that it has finished, and when it started and finished them. Right now it's next to impossible to determine if a task was finished or if it was skipped.

Discussion

I couldn't find anything that looked decent for XSL editing/debugging.

For editing XML files, xmlbuddy comes highly recommended: http://www.eclipse-blog.org/xml/xmlbuddy-for-eclipse.html
Ah, http://www.xmlbuddy.com/ xmlbuddy looks awfully stagnant. Not updated since 2005. :(

Check out oXygen XML at http://www.oxygenxml.com

Comes stand-alone, very powerful. As Eclipse plugin, nearly as powerful.

XSL, XQuery debugging All the editors you need. Very good implementation, clean and functional. Extremley useful. Intelligent programmers. Very good licensing: 30 (60?) day trial, then approx. 70USD/EUR for a 1 year license per user, as many installs as desired, can use any version (stand alone, plugin). The 1 year license means, that you get all the major updates for a year. The minor ones (ie: .x ones) are free without the 1 year update, making the license approx. 40USD/EUR.

I use it since over a year and think it's brilliant. (Along with PyDev, QuantumSQL, Aptana, Subvclipse, Mylyn, Monkey and Buckminster). What can I say ? It's stable.