2

Assuming I have the following:

My::Cool::Klass.call(args)
Cool::Klass.call(args)

Is there anyway I can visually select either the My::Cool::Klass or the Cool::Klass with a quick command?

Note: These are examples, so the strings could be different with two or more nodes (i.e. constants surrounding the :: symbols)

2

If your cursor is at the start of the class, then vt. should work. If it’s anywhere else in the example text then just jump to the start first: Bvt..

0

I don't know ruby very well so I'm not sure what you are exactly trying to do, but if you want to search for strings which are always in the form of aword followed one time or more by ::anotherword you can use the following search pattern:

\w\+\(::\w\+\)\+

This should be pretty straightforward to read:

\w\+              One or more (\+) word characters (\w)
    \(      \)\+  Followed by at least one capture group...
      ::          ...containing two litteral ':'...
        \w\+      ...followed by one or more (\+) word characters (\w)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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