Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure Eclipse word-boundaries so 'Next-Word-Key' skips whole identifier

If I have a piece of Code

  MyIdentifierIsNice(OtherThingAlsoNice isBetterThen);

I'd like to change the behavior of Ctrl-Left in Eclipse from stopping here:

  My|Identifier|Is|Nice|(|Other|Thing|Also|Nice is|Better|Then|);|

to here:

  MyIdentifierIsNice(|OtherThingAlsoNice |isBetterThen);|

...or at least just not so often. Other variants would be also fine, like:

  MyIdentifierIsNice|(|OtherThingAlsoNice| isBetterThen|);|

Mainly it should stop considering a CamelCaseIdentifier to consist of several words for navigation via Next-Word, and such like.

I use SpringSourceSuite Version 2.5.1, which is Eclipse 3.6, I guess.

like image 210
towi Avatar asked Dec 09 '10 14:12

towi


3 Answers

Try and unselect the option:

Preferences / Java / Editor / Smart caret positioning in Java names 

alt text

And see if that enhances the user experience in term of cursor positioning.

If this is not Java, you have a similar option in:

Preferences / General / Editors / Text Editors / Smart caret positioning at line start and end 

It is usually selected, meaning if the cursor still stops at every word, that may suggests another setting for a specific language is overriding it.

like image 161
VonC Avatar answered Sep 30 '22 08:09

VonC


Coming to Eclipse from XCode, I found the default navigation annoying. In Eclipse, Alt+Left and Alt+Right move to the next camelcase segment, and Ctrl+Left/Right does nothing. In XCode, Alt+Left/Right moves between words and Ctrl+Left/Right moves between camelcase segments. This allows you to control how fine-grained your navigation is.

How I fixed this for myself was by going into Preferences > General > Keys, searching for "Word", and changing the "Next Word" and "Previous Word" bindings from Alt+Left/Right to Ctrl+Left/Right. Then the Alt-navigation is by word and the Ctrl-navigation is by camelcase segment, as in XCode.

I thought this might be useful to some.

Edit:

As I continue to use these new settings, I've found another point:

Although navigation works as advertised, selection has some funky behavior. Namely, Shift+Ctrl+Left/Right can sometimes select large blocks of text instead of just the next camelcase component.

To fix this, again go to Preferences > General > Keys, search for "Select".

Set "Select Next/Previous Word" to Shift+Ctrl+Right/Left. Unbind "Select Next/Previous Element" (there are three "Whens" to pick from, I unbound all 3).

Voila.

like image 20
Matt Mc Avatar answered Sep 30 '22 08:09

Matt Mc


If you want a very simple way to select a entire word without the need to disable smart caret positioning.

You can use at the beginning of word or inside the word: Shift+Alt+Right

At the end or in the middle of word: Shift+Alt+Left

like image 33
danilo Avatar answered Sep 30 '22 08:09

danilo