3 ms·
This looks like the sort of thing you would intuitively solve with visual selection and a regex. ``` Vjj:s/\v'(.*)',/'\1': Enum.\u\1,/ ``` This is all j
by mFixman 5y ago
This looks like the sort of thing you would intuitively solve with visual selection and a regex.
```
Vjj:s/\v'(.*)',/'\1': Enum.\u\1,/
```
This is all just muscle memory. It seems impossible until you get used to it, and then it's the most natural thing in the world.
- ARandomerDude 5y agoYes! When I first came from Sublime 2 I thought Vim was irritatingly difficult but hoped it would be worth it. Now I wouldn't program without it.
- chrismorgan 5y agoTIL s/\u, thanks! I know I’ve read that part of the documentation before, but probably not for over five years. In cases where I’ve wanted something like that, I’ve tended to reach for macros, visual block editing, and s/\=. A few days ago I did a somewhat more complicated one that s/\U wouldn’t be sufficient for: :'<,'>s/.*/\=" pub const ".substitute(toupper(submatch(0)), "[^A-Z0-9]\+", "_", "g").": &'static str = \"".submatch(0)."\";"
- mFixman 5y agoVim's documentation is complete and very well-written. I've been using the editor for over 10 years and I still learn new things when perusing :help.