Any refactoring tool like this?
Windows
After you press Alt+Shift+R as mentioned by kostja, you can select the text you want to change, then
Ctrl+Shift+Y for lowercase, or
Ctrl+Shift+X for uppercase.
Mac OS
Cmd+Shift+Y lowercase
Cmd+Shift+X uppercase
There is no intelligence in this. It just blindly changes the case on the selected characters.
note: This tip comes from eclipse help. If you need to find it, click Help, Search, then type "uppercase". You'll find a page with lots of shortcuts.
What I find useful is column select using Alt+Shift+A and select a column of letters.
Then use Ctrl+Shift+Y or Ctrl+Shift+X to lower case or uppercase letters.
This works for eclipse on windows.
There are a number of problems:
fooBar -> FooBar and vice-versa are unlikely to occur unless someone has been ignoring the Java style guidelines. (I rarely encounter such code, and when I do my initial reaction is to write off the code as beyond salvage.)
fooBar -> FOO_BAR and vice-versa are plausible, but pretty unusual.
foobar -> fooBar is also plausible, but it is problematic. It would entail Eclipse figuring out where the intended word boundaries are in a sequence of characters, and that is hard to get right.
If you look at these, they are all either unlikely to be needed much, or too hard to do properly. Hence, it doesn't surprise me that they are not supported by the standard Eclipse codebase.
Pressing Alt+Shift+R gives you all the power to refactor your variable name to your liking. AFAIK, there is no tool or shortcut that does just the capitalizing.
No. You'll have to use the standard rename refactoring and retype the variable name in capital letters.
Capitalizing variable names should be limited to those cases, where we change a class attribute to a "constant", and this doesn't happen that often...
Related
When I like to create a new variable of type ImageObserver and the line starts like this:
IO
and I press Ctrl+Space , I get a couple of wrong suggestions! Suggestions for abbrevs that do not fully match!
Eclipse's content assist suggestions are:
IOException (no! full abbrev is IOE, not IO!)
IOError (no! full abbrev is IOE too, but not IO!)
IndexOutOfBoundsException (no! full abbrev is IOOBE, not IO!)
ImageObserver (yes! full abbrev is IO)
ImageOutputStream (no! full abbrev is IOS, not IO!)
How to get rid of all the other non-full-matching-abbrevs?
Keep in mind that the completion proposals fall into a bunch of categories (ie, lots of different sources of potential matches). Your example text, IO, can logically be interpreted as either a camel-case abbreviation (such as ImageObserver) or as the start of a class name (such as IOException), or even as a camel-case-starts-with match (such as ImageOutputStream, whose abbreviation starts with IO).
I don't know of a tool that's clairvoyant enough to know which of those you want given such a small input. Eclipse, by default, uses a "relevance" ordering for completion proposals and it weighs "starts with" matches ahead of camel-case matches (rightly so, in my opinion). There's no publicly exposed way to change that weighting algorithm, that I know of.
If these are classes or packages that you simply never want to see in Content-Assist, you can define Type Filters to exclude them. In Preferences, go to Java > Appearance > Type Filters to do so. But be aware that Type Filters apply to the entire workspace and in multiple places in the UI, not just Content Assist completion proposals.
You really want IOException to be excluded on auto-complete when IO is typed even though IOException starts with IO?
If so, this sounds like a feature request, but unless you are ready to contribute I can't see it getting added anytime soon.
Contributing
If you are interested in contributing, you need to write a Java Completion Proposal Computer. Once you do that, you can enable only your proposer in the preferences (Java / Editor / Content Assist / Advanced ).
You can even bind your special completer to its own Keyboard Short-cut so you can get "full abbrev" completions only.
Here is a screenshot of my binding of Template Proposals to Ctrl+4 so with a single key combination I can get quickly get them all.
Code Recommenders
I also recommend reading about Code Recommenders, the project adds significantly more sophisticated code completion to Eclipse.
I have raised a bug with Eclipse to see if sorting perfect Camel Case matches could be on the cards.
There are some pretty basic tasks and I'm in doubt how it can be effectively done in Eclipse IDE:
Content assisted variable declaration/assignment:
Imagine you have to write something like this DateFormat df = new SimpleDateFormat();. How can it be effectively typed? One guess like DateFormat df = new plus some quick Ctrl+Space, not very, very long SimpleDateFormat. But this does not work, it will show completely useless alphabetically sorted types from classpath, usually unassignable to DateFormat.
Extracting variable:
Is there any way to extract variable like Alt+Shift+L does but WITHOUT the need to manipulate the mouse to select expression or whole line? Just like extract content under cursor? Or is there some way to select line (this work only for standalone expression but better than mouse)?
Extracting field:
Any way to extract field in more convenient way than perform 2. followed by another magic - convert variable to field?
I'm doing mentioned combos every 1-5 minute, and it seems to me like editor completely unusable for serious work. (Iff one is not Ray Manzarek)How are you typing in Eclipse? Note that I prefer default settings, no fine-tuning which stops working after first upgrade or terminal change. Thanks.
For your first problem, here's how I do:
DateF<ctrl-space><Enter> df = new SDF<ctrl-space><Enter>
For your second problem, I simply select the text I want with ctrl-shift-left_or_right_arrow.
For your third problem, no idea. I don't remember having transformed a local variable into a field for a long long time. Maybe I just know beforehand which fields I'll need for a given class.
For the first one, I find I just need to type DateF Alt-\ Enter df = new Sim Alt-\ Enter ;, which doesn't seem too bad to me.
For your second question Shift-Option-Right extends the selection to the right one word at a time, and Shift-Option-Left to the left; that, in combination with the keyboard shortcut you mention, should do what you want (those are Mac keys, of course, but I'm sure there are Windows equivalents; I understand some folks actually develop software on Windows.)
For number three: don't think so. You could write your own plugin to do it pretty easily.
I am using Eclipse 3.6.1 Build id: M20100909-0800 and Aptana Studio 2.0.5 which is based on Eclipse 3.5.2 (both on OS X) and in both programs the external tools feature seems to swallow double quotes and whitespace for the ${selected_text} variable.
Isn't the ${selected_text} variable essentially useless with the mentioned behaviour?
Is there a way around that or maybe a hidden setting somewhere?
Thanks for reading.
This could easily be considered a safety/security feature.
I suggest "${selected_text}".
...but if it's eating ALL whitespace, that won't really help. Huh. Maybe it's clever enough to detect the quotes and preserve the whitespace... but probably not.
Okay, I did a little poking around. Quotes within the argument list itself are preserved, as per my initial suggestion above. I found the following auto-generated argument list that was working Just Fine:
-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog
-debug "${workspace_loc:/com.cardiff.bpm.ide.webforms.ui/debug.options}"
But if your text selection contains quotes, I'd expect it to be handled as per the underlying OS. Windows "cmd" does some... creative things with them for example. My *nix-fu is Not Mighty, so I couldn't tell you what OS X will do under the covers, but I suspect that's where you'll find your solution.
You may have to do something goofy like URL-encode your selection, and use some command line tool to un-encode it before passing it to your desired external tool once the text is out of Eclipse's clutches.
A (very) quick look around my 3.6.1 UI didn't turn up that would do this automagically for you, but there's probably a plugin out there somewhere that'll add that feature to an editor's context (right click) menu.
I'd expect the HTML editor to have this ability already... but I don't see anything other than "smart insert mode" that sounds promising, and I don't see that working either.
That doth bloweth goats, most heartily, yay for weeks on end. E'en till yon goat hath a rash, most unpleasant in both severity and locality. Verily.
I don't think you're getting my proposed solution:
Set up your tool so it'll de-url-encode-ificate the incoming string with some proposed command line tool.
In your editor (in eclipse), URL-encode the text you wish to select and pass to the tool. Manually.
Run the tool on the selected (url-encoded) text.
Revert the selected text. Also manually. Probably just "undo".
"1" is why I was looking for some eclipse UI way of url-encoding a selection. The HTML Editor won't even do it when you paste into an attribute string. Sheesh.
Two Other Options:
Fix the bug yourself. Open Source and all that.
Write a plugin that exposes it's own version of ${selected_text} that doesn't strip out all the strings.
Hey! SED! Replace the quotes with some random (unused in any selection you might make) high-ascii character and sed it back to a double quote instead of the proposed de-url-encode-ificationizer. You'd still have to manually edit/undo the text, but at least you won't have to """ Actually search/replace over a given selection makes that less painful than one might think.
I'm not sure what the scope of #2 is, but I'd image if you don't have any eclipse plugin experience the thought might be rather daunting. There might even be a sample plugin that exposes such a variable, though I haven't checked.
I don't think we're communicating.
You don't select text with quotes in it. You select mangled text, and sed demangles it back into quotes for you.
For example, you have the string print("hello world"); in your editor and want to send that to your tool.
change it to print(~hello world~); in your editor. Manually or via a script or whatever.
select it
run your tool, maybe wrapped in a script that'll sed the ~s back to "s.
change it back to print("hello world");.
This is a manual process. It's not pretty. Bug workarounds are like that. You can probably come up with a monkey script to convert quotes to Something Else, and "undo" is easy. You might even be able to get your script attached to a keyboard short cut... dunno. And ~ is a lousy choice for a replacement character, it's just the first thing I could think of that was rare enough to be a decent example.
Are we communicating yet?
For the record, I put together a patch using some guidance from a gentleman in the bug comments.
I don't know if it will be accepted, but it fixes things for me so maybe someone else may find it useful.
Again, this is only for Mac OS X Eclipse.
Start Eclipse.
Go to Import > Plug-ins and Fragments.
Import From: Active Platform
Fragments to import: Select from all plug-ins
Import As: Projects from a repository
Next >
Pick org.eclipse.debug.ui and org.eclipse.debug.core
Once the projects are in your workspace, apply the two patches that compose proposed patch v1, found at the bug tracker page for bug 255619
Go to Export > Deployable plug-ins and fragments and make a jar out of your changed packages.
Hope it helps.
My NetBeans dictionary is kind of... illiterate? It's flagging words like "website" and the "doesn" part of doesn't. I right-clicked expecting to see your standard Add to dictionary... option but found none. I browsed the menus and also found nothing.
How do I educate my NetBeans spellchecker?
It looks like the spell checker is a relatively recent addition. There are basic instructions on how to change the dictionary here.
Adding an unknown word to the dictionary requires alt + enter while the cursor is on the 'misspelled' word. This might take care of the most glaring omissions.
If it highlights just 'doesn', then it probably isn't aware of English-style contractions (i.e., it doesn't know that words can span across an apostrophe). Until that is fixed, I would recommend just adding 'doesn' as a separate word using the above method.
There's a lot of Text editors which support autocomplete during programming, but I want one which can autocomplete while typing normal text as I see a lot of repetition of words I type. Any emacs fans who have implemented this ?
Try the builtin dabbrev-expand; it's bound to M-/.
Also see Predictive Mode if you fancy the more flashy stuff.
pabbrev-mode (predictive abbreviation) works by examining previously written text. Unlike dynamic abbreviation, the text is analyzed during idle time (which enables quick lookup of potential abbreviations). Pabbrev looks at word frequency to suggest the most common expression.
From the documentation, this is what it might look like as you typed the keys pred.
p[oint]
pr[ogn]
pre[-command-hook]
pred[ictive]
I love hippie-expand!
The Zeus editor has a non-programming auto complete feature (i.e. Alt + Space) that takes the current user input, searches the current file for words starting with that input and displays them in a drop down list.
vim has such a feature http://vim.wikia.com/wiki/VimTip4
i think ultra edit has a simmilar feature
You could set up auto-complete mode with a dictionary as your source. I have been very tempted to do this myself.
predictive-mode auto-completes from a dictionary of words. It learns which words you use most often, and can also automatically learn new words as you type if desired.
It's very fast, fast enough that turning on auto-completion doesn't cause any noticeable lag when typing, even with a large dictionary.
(Disclaimer: I'm the author of predictive-mode)