Hacker News new | ask | show | jobs
by uglycoyote 1279 days ago
I'm skeptical about vi/vim but I like to watch videos like these occasionally to see what I'm missing out on. But I lost interest here as soon as he said he was going to avoid using regular expressions. Of course you would use regular expressions to do this task. It makes zero sense to me to commit a bunch of vim -specific tricks to memory instead of practicing regexes which work not only in vim but in almost any decent editor or programming language.

for a task like this, I would often prove it out with regex search and replace in an editor and then if I felt like I was going to need to repeat the task often, turn that into a script

I feel like many people are unnecessarily afraid of regexes but they are a much more broadly useful tool than vim commands

1 comments

Like he said that was just one technique - he was probably doing it to show viewers something they may not already know, like using a regex. The technique I would use for this is the one that requires the least thinking and the one I usually use in general - record a macro that does one line and moves to the next, and then run it to the bottom.