Sunday 20 January 2019

Is there an easy way to use Vim text-objects on camel case words?


Often I'll be doing a quick edit to a camel case word in some code and wish I could use something like text-objects to select one part of the camel case word.


For example, given this snippet:


class TextObject:
pass

If my cursor is on the 'x' in TextObject, I would like to quickly select/operate on the word 'Text'. If my cursor is on the 'j', I would like to manipulate the word 'Object'.


Vim text-objects allow me to quickly manipulate the entire word TextObject (e.g 'caw'), but I've noticed that I quite often want to manipulate only a single word in a camel case string like this.


Any pointers?


Thanks in advance



Answer



This is exactly what the CamelCaseMotion script is for. I use it all the time.


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...