How to create new key-bindings for ecplipse - java

Most germans probably know the hassle to reach specific symbols like "{" or "}" within the german keyboard layout, that are often used, when programming in java.
Does anyone know a simple way to rebind those keys for the java editor in eclipse? I'd love to have it the following way, but I am open to alternatives too, as long as they are easy to reach:
ALT GR + Ö results in "{"
ALT GR + Ä results in "}"
I tried several third party keybinding tools like Sharpkeys, but most of them don't recognize those specific german keys within their layouts. I also tried inner eclipse solutions like templates, but those don't feel naturally to use, since you can't bind them to a key. I also tried macro add ons, but those usually can only hold the last recorded macro.
Anyone with a nice clean idea on how to solve this?
OS = Windows 10

You could do the following to type ö/ä followed by Enter for {/}:
In Window > Preferences: Java > Editor > Templates:
Click New...
Enter/choose the following values:Name: öContext: JavaDescription: {Pattern: {
Repeat the last two steps for ä and }
In Window > Preferences: Java > Editor > Content Assist add öä as Auto activations triggers for Java (by default it is ., so change it to .öä)
Result: In the Java editor, if you type ö/ä, the content assist automatically opens and hitting Enter will select the ö/ä template.

Related

Is it possible to tweak the settings so it automatically places quotations when using System.out.println()?

I am using java on Intellij and I wonder if it is possible to make it so that it automatically places quotations System.out.println(here);
Thanks
Yes, it is possible.But a bit tedious. (EDITED)
ECLIPSE
you need to know that Ctrl+space opens options for autofill.
you need to create a simple template at
Window>Preferences>Java(dropping menu)>Editor>Templates>New...
In the open window at Name type: Syso
at Pattern: System.out.println("")
Make sure the checkbox Automatically insert is on.
Apply and close
Now every time you type Syso and hit Ctrl+Space there will be first option
of autofill with quotations. Profit.
oof, didn't notice about Intellij , my bad. Thought about Eclipse. Well here is one for Intellij
INTELLIJ
I believe the Intellij version of cntl+space is Tab button
Go to Settings>Editor>Live Templates
Pick any template and press Plus icon. Choose Live Template
In abbreviation type your desired word (I would put: Syso)
In Template txt type : System.out.println("")
Make sure the box with Reformat according to style is checked
Now every time you type Syso you can hit Enter and have PROFIT!

Multi-line block select using the keyboard in IntelliJ IDEA on a Mac OS X

I've recently switched from Eclipse to IntelliJ IDEA 13. I use the VI keybindings.
One non-vi thing I am used to doing in Eclipse is using Shift + ↑ / Shift + ↓ to block a few lines of text. The behaviour of this text selection in Eclipse is the same as almost every other text input widget I've ever used. Typically I do one of two things after making the selection - delete this block or comment it out (⌘ + /).
I have no found equivalent keyboard-only multi-line selection function in IntelliJ IDEA 13.
Shift + ↑ does not start a block selection - it seems to page the cursor up and down the screen.
If I use the mouse to start making a selection, then the arrow keys do extend the selection. However, I'm unable to start a selection using the keyboard alone.
I'm aware of the ⌘ + W ever-outward-growing smart element selection - but if you then use the arrow keys, the selection is lost, not extended.
How can I start and then extend a selection region across multiple lines using the keyboard only on Mac OS X (that works with the VI keybindings enabled)?
Multi-line caret
For Mac, you can use ⌘+⌘(Hold)+↑ / ↓.
For Windows, replace the ⌘ with CTRL.
ESC will end multi-line mode.
Change Multi-caret Hotkey
To add a custom Keymap, ⌘+SHIFT+A, type keymap and click on the one with Settings as subtext. Search for Clone Caret Above and Clone Caret Below.
I mapped mine to ALT+SHIFT+↑ / ↓.
Bonus
Try holding combinations of ⌘, SHIFT, and arrows for improved selection power.
Sounds like you need to map it. In the default key mapping Shift+↑ and Shift+↓ work as expected (i.e. as you describe). I do not have the vi mapping available to check it. Go into Settings > [IDE Settings] > Keymap. In the Keymap, go to "Editor Actions". Configure the "Down with Selection" and "Up with Selection" options. This may mean removing the Shift+↑ and Shift+↓ mappings from something else.
I use the IdeaVIM plugin on Mac OS and I can increase or decrease my selection with the keyboard only with alt-Up/Down.
It is possible I customized the VIM keymap to this, can't remember if it is default or not. However, the editor action you are looking for in the keymap settings is "Select Word at Caret" and "Unselect Word at Caret". Repeatedly pressing the keystroke smartly selects/unselects the text. It almost always selects what I want.
You can use alt+Up/Down/Right/Left or alt+mouse-select to block select on mac in IntelliJ

What are the different eclipse shortcuts available?

I wanted to know the different eclipse shortcuts available like when we wanted to write this
System.out.println(); then we simply write syso and hit ctrl+space
then we get System.out.println();.I do not want shortcuts like for copy ctrl+c or to cut ctrl +X
screenshot of templates
These are called "editor templates", and you can see the full list in
Window --> Preferences --> Java --> Editor --> Templates
You can also create your own there, with various placeholders, e.g. I have one isequalto defined like this:
${:importStatic(org.fest.assertions.api.Assertions.assertThat)}assertThat(${actual}).isEqualTo(${expected});
This will automatically add a static import and add cursor positions that can be navigated to with TAB. This can be invoked by typing isequalto (or just ise) and ctrl+SPACE.
For a try/catch bock, just type try and ctrl+SPACE.
What you're looking for are not shortcuts, but Templates.
Open Window -> Preferences -> Java -> Editor -> Templates and you'll see the full list.
You can even add your own templates.
GO to Help Menu in Eclipse
And Click Key Assist
The shortcuts your referring to are called templates.
You can view them all in the IDE or make your own:
Window > Preferences > Java > Editor > Templates
Basically to use any of these templates, type their name followed by CTRL + SPACE. Once you have enough of the name typed that the name is distinct, for instance syso you can use CTRL + SPACE. So you may not need to type the whole name.
see Eclipse Short Cuts
It may be for Eclipse 3 but those shortcuts have been standardised for a while.

remove indentation in source code

I use Eclipse IDE and Window Builder Pro for create window.
When I go to the source code I see a big indent text. How to delete ?
How about good old Shift + Tab?
If by "how to delete" you mean to say that you want to decrease the indentation level, try this:
Go to
Window->Preferences->general->Editors->Text
Editors
There specify the indentation level under :
Displayed Tab Width.
Additionally you can customize you formatting in Eclipse as :
Go to
Window->Preferences->Java->Code
Style->Formatter
Select the formatter and press Edit. Use whatever suits you.
Then Select the text you want to format and press Ctrl+Shift+F
If you want to fix indent only you can select lines and press Ctrl-I.
Take a look at Eclipse keys
Most likely you insert tab character which is being expanded to 8 positions in target IDE.
Change setting in Eclipse to insert 4 spaces (or whatever your style is) when tab is pressed.
Then you can try to reformat your file in Eclipse. Also, you can use sed to replace \t with 4 spaces.
If you like the way your formatter is set up for the rest of your code, perhaps telling the formatter not to work on this section would be desirable. Then you can unindent the section to make it visually appealing and not worry about it changing formatting.
Linked solution works in Eclipse 3.6.

Improving Eclipse autocompletion?

Currently the Eclipse autocompletion seems only to be triggered after a dot or on parameters, I want to use it for variables too, e.g. if I have
String test="hello";
then I want the autocompletion to suggest "test" if I start typing "t" in the next line (e.g. if I intent to change the value of the variable test).
Is there any Eclipse plugin capable of doing this? I already checked the Eclipse content assist options, but seems like there no option for what I want? Thanks for any hint!
First of all, thanks for all the replies. They are correct, however you have to press the key combination each time. Here's how it's done automatically:
That plug-in is not necessary any more. Just go to
Preferences > Java > Editor > Content Assist
and paste:
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.
into the "Auto activation triggers for Java:" field.
This simply triggers auto activation after any English alphabet character and after dot.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=159157#c12
Works fine :-)
Hint: You probably want to additionally set the auto activation delay to 0, at least if you are used to visual studio ;-)
In addition to the suggestions above, did you try ALT + / it does incremental matching? No?
ctrl + space
If you press ctrl+space key combination, eclipse will show you the code assist window.
Type t and then hit ctrl+space, it will show you possible matches
You can press "t" and then Ctrl+Space..
is it?
In Eclipse
Window--->Preferences---> search for Content Assist under Content Assist go for Advanced
and check the Java Praposals.
done.

Categories