[]RSS

About Archives Artwork Comic Contact Philosophy Projects Tags

Textmate command #0

August 31st, 2007 in Micro Blog

Here’s my first pass at a Textmate command (for the E text editor). It copies the text selection to a multi-line C constant, useful for pasting SQL statements into C code:

perl -p -e 's/^(\s+|)(.*)( |)(\s+|)$/$1\"$2$3\"$4/' | pbcopy
echo "Copied C-SQL to Clipboard"

The regex preserves whitespace after each line of statement within the quotes, and preserves the indent so you can still read the SQL in your C code.

 

Leave a Reply

Subscribe to comments