For example, if I have the following, with my cursor on the starting ‘s’:
What I want is for
w to take me to the capital
L, then to the capital
M, then the
C, and so on. Similarly with this code:
I’d like to be able to jump between the underscores.
I’ve never been able to find a way to do this until now. The solution is the brilliant CamelCase Motion plugin. This provides commands for jumping intelligently, as I described above, and works with both CamelCase and snake_case.
What I’ve done is simply map w, b and e to the CamelCase versions:
map <silent> w <Plug>CamelCaseMotion_w map <silent> b <Plug>CamelCaseMotion_b map <silent> e <Plug>CamelCaseMotion_e sunmap w sunmap b sunmap e
Thank you to Reddit user “nandryshak” for mentioning this in a r/vim thread.
w, b and e will now work mostly as before, except when it detects camel casing or snake case, at which point it will act accordingly. Perfect!
comments powered by Disqus