I am trying to search backwards (using ?) for the beginning of a "word".

I don't mean a word in the text object sense; I mean a series of lower-case letters optionally beginning with a capital letter. The optional capital letter is stymying me.

Here are some examples showing where I want to jump to, assuming the cursor starts at the end of the line:

quick brown fox
^     ^     ^

^    ^    ^

Quick Brown Fox
^     ^     ^

^     ^     ^

The closest I've come up with is ?\(\U\u\)\|\L?e+ – but that doesn't work with the capital letters. I assume this is because \L matches before \U\u does.

How can I solve this?

2 Answers 2


This simple search works for all the examples you gave:


It matches any alphabetic character (upper or lower case), followed by any non-zero number of lower case characters.

Some examples of cases you didn't mention where I'm a little unclear what you want it to do:

match a lower case

If you want it to match the single letter word a/A in both of these, then use a * instead of the \+:

  • @andy-stewart I'm also unclear on whether you need the regexp to only match the first letter in the word. My answer moves the cursor in the way you describe, but matches the whole word.
    – Rich
    May 26, 2017 at 11:06
  • Much iimprove, so amaze, wow May 26, 2017 at 12:20
  • This however wouldn't work with qui1ck brown fox because of the number, but can bi fixed with something like [a-zA-Z][a-zA-Z0-9]\+ May 26, 2017 at 13:42
  • @user1685095 Yes! But again, it's not clear from the question what the OP actually would want it to do in that situation.
    – Rich
    May 26, 2017 at 13:45
  • yes, absolutely. It's probably about programming. So digits inside a word are possible. But still that's a conjecture. Judging by his silence - he's already solved the problem by himself. May 26, 2017 at 13:59

Although ugly this does what you need. At least in your example. I think it could be simplified, but wouldn't bother to do so. \(\<\|\([a-z0-9]\?\(\( \|_\)\zs\|\zs\u\)\)\)

With very magic \v(<|([a-z0-9]?(( |_)\zs|\zs\u)))

  • You're welcome! May 26, 2017 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.