31

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.

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
towi
  • 21,587
  • 28
  • 106
  • 187
  • 2
    That camelcase navigation so insanely annoying. Some dude requested that weird behavior and they made it default... On top of that, eclipse that comes with android SDK totally doesn't handle properly Ctrl+Left/Ctrl+Right... – Pavel P May 13 '13 at 17:47

3 Answers3

42

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.

Edward Brey
  • 40,302
  • 20
  • 199
  • 253
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I think I tried that before I posted the question. But I will re-check. Thanks. – towi Jan 13 '11 at 06:39
  • 1
    I wonder, what if I still need to be able to jump to next camel-fragment of the word in some other way. E.g. in Xcode I can iterate though words with `alt+arrow` and though camel case with `ctrl+arrow`. How do I do it in eclips? – DanSkeel Jun 05 '12 at 08:53
  • @Danich I didn't see that feature, either in Eclipse nor in a plugin. I only saw this Camel completion study for CDT: http://wiki.eclipse.org/CDT/C_editor_enhancements/Camel-case_completion. But it doesn't cover your case. – VonC Jun 05 '12 at 17:41
  • It seems so obvious feature... What is the most efficient way to ask them about it? I think may people need this functionality. – DanSkeel Jun 05 '12 at 19:41
  • @Danich Probably making a feature request on https://bugs.eclipse.org/bugs/, and ask as many people as you can to vote on it. – VonC Jun 05 '12 at 20:55
  • 5
    With this option disabled, Ctrl+Left/Right treats each individual tab character as a "word", which is a nightmare for users who indent with hard tabs. It also treats both the beginning and end of `_` in a Java identifier as a word boundary, so you'll have to hit Ctrl+Right 3 times to skip past the identifier `x_y`. – Sam Harwell Feb 21 '13 at 15:26
  • 3
    _Smart caret positioning at line start and end_ has nothing to do with this. – RedGlyph Jan 18 '14 at 17:01
  • 1
    @DanSkeel As a fellow XCode user, I agree. I did figure this out, and it's posted here as an answer now. – Matt Mc Mar 03 '14 at 00:08
10

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.

Matt Mc
  • 8,882
  • 6
  • 53
  • 89
1

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

danilo
  • 7,680
  • 7
  • 43
  • 46