Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

For that I would probably have used a regex search and replace in any decent editor, or perhaps a Perl one-liner.

cat file | perl -p -e 's-\s(.)\.rb-// Run the $1 command\ndef $1()\nend\n-'



As a heavy user of regex one liners, I agree in this case, but as a heavy user of vim, there are lots of times when a macro can be recorded and run over a file long before a proper regex can be constructed, particularly in multi line settings, or those things that would require heavily nested backrefs.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: