Command line goodness

categories: command line, front-end development

Two good ones from today:

cygwin/perl: change all references to portfolio.html to portfolio_d.html.

perl -i -p -e 's/portfolio\.html/portfolio_d.html/g' *.html

More perl command line goodness here.

vim: on every line that has an element with an id attribute, take the value of that attribute and use it as the argument for a php command.

g/id="\([^"]\+\)"/ s/id="\([^"]\+\)"/value="<?php $io->p('\1'); ?>" id="\1"/

More on vim and regular expressions here. Also: shell commands from inside vim.

I've been gradually moving completely away from Dreamweaver as my editor because I really prefer the mouse-less navigation of vim, and stuff like this helps me replicate features I miss (like search and replace across multiple files) and take them to a whole new level at the same time.

Comment