TextMate uses the (?m:<regex>)
in order to math the regex regex
as multi-line. For example, in order to match everything between and including the tags <p>
and </p>
, you would search:
(?m:<p>.+?</p>)
As an example, the above regex will match the following input:
<p> Good Day! </p>
The Macromates-TextMate blog presents a script how to hard-wrap lines using a simple regular expression. In order to add this feature to TextMate, open TextMate and select the menus Bundles→Bundle Editor→Edit Commands…
and then press the plus sign (+
) to create a new command:
The script that must be entered should be:
#!/usr/bin/env ruby # Wraps selected text to 76 def wrap_text(txt, col = 76) txt.gsub(/(.{1,#{col}})( +|$)\n?|(.{#{col}})/, "\\1\\3\n") end STDOUT.sync = true print wrap_text(ENV['TM_SELECTED_TEXT'])
If you have used a recent version of TextMate, you will notice that GPG Tools do not play well with it and that if select some text, then go to services, you will not find an option to encrypt or decrypt text. The problem lies with GPG Tools, in the file located at /Library/Services/GPGServices.service/Contents/Info.plist
. GPG Tools bundles a fixed list of utilities by the bundle identifier for which certain actions such as encrypt or decrypt are available. Unfortunately, GPG Tools defines a bundle identifier of com.macromates.TextMate.preview
for TextMate and the TextMate bundle identifies itself as com.macromates.textmate
.
Changing the Info.plist
on GPG Tools does not work because GPG Tools performs some checking on the files to determine if they have been tampered with. Instead, we can change the TextMate bundle identifier by editing the file at /Applications/TextMate.app/Contents/Info.plist
. Change the line reading:
CFBundleIdentifier = "com.macromates.textmate";
into:
CFBundleIdentifier = "com.macromates.TextMate.preview";
and then restart TextMate. On the next run, the GPG Tools will offer their services.
Create the file ~/.tm_properties
and add softTabs = true
. The following line executed as the current user will append softTabs = true
to ~/.tm_properties
:
echo 'softTabs = true' >> ~/.tm_properties
You can also add tabSize = 4
to ~/.tm_properties
in order to use 4 tabs by default.