Quick Textmate Productivity Tip
Today I found myself needing a bit of Textmate magic. I had a sql-file containing a lot of tables, from some of these I needed all fieldnames in an array. I quickly found that Textmate would be my friend. This is mostly a reminder to myself. (I tend to forget these things somehow).
I Pasted all the lines with fieldnames from the sql-file to a new text-document in Textmate. Then i pressed option while using the mouse to mark the beginning of each line and then inserting a quote. (Resulting in a quote on the beginning of each line.) I did the same on the other side of the textfields and added a comma as well. The only problem now is that because not all fieldnames are the same length I now have some unwanted whitespace between the end of the fieldname and the closing quote. Enter regexp, and probably the simplest one I ever wrote.
[ ]
It simply matches all whitespace in the file. Thus making it easy to use find/replace, and replace the whitespace with nothing. Downside is, all the time I saved using this technique has been used to write this blog post. :-)
