Howtos
Main.Howtos History
Hide minor edits - Show changes to markup
You can now edit textareas by right clicking and choosing MozEx ->Edit textarea. The text will open up in TextMate which you can then edit. When you have finished and saved the file, you just need save the file or, click in the textarea for the contents to update with the changes you made in TextMate.
You can now edit textareas by right clicking and choosing MozEx ->Edit textarea. The text will open up in TextMate which you can then edit. When you have finished and saved the file, you just need save the file or, click in the textarea for the contents to update with the changes you made in TextMate video game parts.
- Minsk Apartments
- KES-410A
- KES-410A
- Minsk Apartments
- [Minsk Apartments](http://www.yourminskapartment.com/)
- [Minsk Apartments](http://www.yourminskapartment.com/)
- Input: Current Word
- Input: Selected Text OR Word
- Command: #!/bin/bash
- Command: [@ #!/bin/bash
find "$TM_FILEPATH" "$SEARCHPATH" -type f -name '*.rb' -exec sed -En "/$STARTPATTERN/,/$ENDPATTERN/p" {} \; |sed -E "/$ENDPATTERN/q"
find "$TM_FILEPATH" "$SEARCHPATH" -type f -name '*.rb' -exec sed -En "/$STARTPATTERN/,/$ENDPATTERN/p" {} \; |sed -E "/$ENDPATTERN/q" @]
- Command: <pre>#!/bin/bash
- Command: #!/bin/bash
</PRE>
Lookup class or method definition (2)
- Input: Current Word - Command: <pre>#!/bin/bash SEARCHPATH=$(test -x "$TM_PROJECT_DIRECTORY" && echo "$TM_PROJECT_DIRECTORY" || echo $(dirname "$TM_FILEPATH") ) STARTPATTERN="^(:space:?|;)*(def|class)(:space:?|;)+$TM_CURRENT_WORD([^A-Za-z0-9_].*)*$" ENDPATTERN="^(:space:?|;)*end(:space:?|;)*" (egrep -ns "$STARTPATTERN" "$TM_FILEPATH" || egrep -nsR "$STARTPATTERN" --exclude="*.svn*" "$SEARCHPATH") |cut -d: -f-2 find "$TM_FILEPATH" "$SEARCHPATH" -type f -name '*.rb' -exec sed -En "/$STARTPATTERN/,/$ENDPATTERN/p" {} \; |sed -E "/$ENDPATTERN/q" </PRE>
- Output: Show as tooltip - Activation: Key Equivalent: CTRL+]
Check this post: http://claudiofloreani.blogspot.com/2011/10/add-shortcut-to-textmate-to-lookup.html
Time Tracking
TimeTap
TimeTap: the unobtrusive time tracking for TextMate It stays in background and presents your stats in a useful web interface. Install it from Rubygems.org.
This can be done by searching for a regular expression where "\b" (word separator) is prepended and appended to the searched word. i.e searching for "\bMessage\b" instead of "Message".
This can be done by searching for a regular expression where "\b" (word separator) is prepended and appended to the searched word. i.e searching for "\bMessage\b" instead of "Message".
How To Cut Short the Wait for TextMate 2
Are you fed up with waiting for TextMate 2?
Would you like to run the mythical editor right now?
Here's how to do it on Mac OS X. Just follow these three easy steps:
1. Design and code a clone of TextMate. Be careful! Your app needs to run as well as the present one and include all announced new features to really be called TM2.
2. Put your code in a directory containing TextMate.xcodeproj
3. Compile using XCode and copy the result to /Applications.
It's as simple as that. And remember, Beethoven wrote his second symphony 6 years after his first.
-O.B.C Hashfunk's Featherweight Folio of Worthwhile Workarounds and Decorative Stitches
input: entire document output: insert as text
Input: Entire Document Output: Insert as Text Scope: source.php, source.js
Command:
Collects all defined functions (name+params) in the document and inserts a commented out list of them at caret's position, right padding with spaces lined up to 4 columns after the longest name-(params).
[=
Collects all defined functions (name+params) in the document and inserts a commented-out list of them at caret's position, right padded with spaces lined up to 5 columns after the longest name+(params).
[=
=]
=]
List Functions in Page - M Spreij
Collects all defined functions (name+params) in the document and inserts a commented out list of them at caret's position, right padding with spaces lined up to 4 columns after the longest name-(params).
input: entire document output: insert as text ------------------- #!/usr/bin/php <?php while ($fetch = fread(STDIN, 1000)) $data .= $fetch; if (! $data) exit; if (preg_match_all("/function (.*) {/", $data, $matches)) { unset($matches[0]); $matches = $matches[1]; echo "/** -- Functions -------------------------\n * \n"; $postfix = max(array_map('strlen', $matches)) + 7; foreach($matches as $match) { echo str_pad(' * '. $match, $postfix) . "\n"; } echo " * \n * \n**/\n"; }
$fetch = fread(STDIN, 100); if (! strlen($fetch)) {
return;
}
$data = $fetch;
while (strlen($fetch)) {
$fetch = fread(STDIN, 1000); $data .= $fetch;
}
while ($fetch = fread(STDIN, 1000)) $data .= $fetch; if (! $data) exit;
PHP Project Functions - Dion Almaer
=]
Run PHP, show as HTML - M Spreij
Runs the PHP code in the [unsaved] HTML document, then shows the result rendered as HTML.
[=
Input: Entire Document Output: Show as HTML Scope selector: text.html, source.php
Command:
- !/usr/bin/php
<?php $data = ''; while ($tmp = fread(STDIN, 1000)) $data .= $tmp; if (! $data) return false;
$data = "?>$data<?php"; eval($data);
LaTeX
Whole word search
Whole word search meaning that when searching for "Message" you will not find "sendMessages" too, just occurrences where "Message" is the whole word.
This can be done by searching for a regular expression where "\b" (word separator) is prepended and appended to the searched word. i.e searching for "\bMessage\b" instead of "Message".
To format your own dates (such as "10/7/2008"), use the formatting codes for the Unix date command (see Wikipedia)
To format your own dates (such as "10/7/2008"), use the formatting codes for the Unix date command. See Wikipedia.
(Commands to do the same thing without invoking PHP or Perl.)
(I give it the key command: Command-Option-Shift-F to match BBEdit's "reformat HTML code" command.)
FHTML-TextMate.txt
(I give it the key command: Command-Option-Shift-F to match BBEdit's "reformat HTML code" command.) Note the new link to Snipplr.
http://snipplr.com/view/28256/fhtml-for-textmate/
import string
output_str = string.join(result, " + ")
output_str = " + ".join(result)
- Run preg_replace_callback to take variable declarations
- Run preg_replace to take variable declarations
php -r 'echo preg_replace("|(\w+) (\w+) (\w+):(\w+);|e", "\"\npublic function get\".ucfirst(\$3).\"():\".\$4.\" {\n\treturn \".\$3.\"; \n}\n\n\".\$1.\" function set\".ucfirst(\$3).\"(\".\$3.\":\".\$4.\"):Void {\n\tthis.\".\$3.\" = \".\$3.\";\n}\"", file_get_contents("/dev/stdin") );';
php -r 'echo preg_replace("|(\w+) (\w+) (\w+):(\w+);|e", '"\npublic function get".ucfirst($3)."():$4 {\n\treturn $3; \n}\n\n$1 function set".ucfirst($3)."($3:$4):Void {\n\tthis.$3 = $3;\n}"', file_get_contents("/dev/stdin") );';
php -r 'echo preg_replace_callback("|(\w+) (\w+) (\w+):(\w+);|", create_function("\$matches","return \"\npublic function get\".ucfirst(\$matches[3]).\"():\".\$matches[4].\" {\n\treturn \".\$matches[3].\"; \n}\n\n\".\$matches[1].\" function set\".ucfirst(\$matches[3]).\"(\".\$matches[3].\":\".\$matches[4].\"):Void {\n\tthis.\".\$matches[3].\" = \".\$matches[3].\";\n}\";"), file_get_contents("/dev/stdin") );';
php -r 'echo preg_replace("|(\w+) (\w+) (\w+):(\w+);|e", "\"\npublic function get\".ucfirst(\$3).\"():\".\$4.\" {\n\treturn \".\$3.\"; \n}\n\n\".\$1.\" function set\".ucfirst(\$3).\"(\".\$3.\":\".\$4.\"):Void {\n\tthis.\".\$3.\" = \".\$3.\";\n}\"", file_get_contents("/dev/stdin") );';
This works great for Transmit also, just replace "Interarchy" with "Transmit". -- natebeaty
Applescript to trigger Transmit "DockSend" with command - Provided by natebeaty
This line of code sends the active TextMate file to Transmit. If the file is on a path specified in a DockSend-enabled favorite, the file will be automatically uploaded to the server.
osascript -e 'tell app "Transmit" to open POSIX file "'"$TM_FILEPATH"'"'
Python
Textmate-Ropy AutoCompletion - Ikuta Lin
- Install rope - hg clone http://bitbucket.org/agr/rope/ - sudo easy_install rope - Install Textmate-Ropy - svn checkout http://textmate-ropy.googlecode.com/svn/trunk/ textmate-ropy-read-only - C-P - Autocompletion - C-] - Search class or methond defination
LaTeX
Steve King adds: You can do this globally instead of project-by-project by opening the Preferences window and going to "Advanced", "Folder References".
Steve King adds: You can do this globally instead of project-by-project by opening the Preferences window and going to "Advanced", "Folder References".
How to use timed autosave with Textmate
Textmate doesn't include timed autosave. I thought that feature would simplify my workflow with typing LaTeX documents.
In conjunction with latexmk, autosaving allows almost for an WSIWYG environment (More details about the continuous monitoring ability of latexmk: http://jon.smajda.com/blog/2008/03/08/latexmk/). You avoid the need save the document yourself and by that invoke latexmk.
Make autosaving work with Textmate:
1. Get the freeware Eversave from http://www.tool-forcesw.com/eversave/ and install it
2. In preference of Eversave: Under "When should Eversave save:" pick "Time-controlled"
3. Under "Automatically save these applications" pick Textmate
4. Under "Timer" set how fast you want it to be saved (for the LaTeX application I mentioned earlier, it should be <5s)
5. CRUCIAL: under "Please choose a save method" pick "Save by simulating save shortcut (more compatible)" as the other method does NOT work with Textmate (it will invoke the "Save as" command instead of the "Save" command, which is useless for our (most) purposes).
That's it.
- [[#TemplateAuthoringDates | Formatting Dates in Templates
- Template Authoring
- [[#TemplateAuthoringDates | Formatting Dates in Templates
Template Authoring
Formatting Dates in Templates
Default templates contain this code:
TM_DATE=`date +%Y-%m-%d`
which produces a date like "2008-10-07"
To format your own dates (such as "10/7/2008"), use the formatting codes for the Unix date command (see Wikipedia)
To put spaces in your formatting code (such as in "7 October 2008"), you need to wrap your formatting codes in double quotes:
TM_DATE=`date +"%e %B %Y"`
To the uninitiated (such as myself) that doesn't look like it should work, but it saves the day.
Save: Current File \\
Save: Nothing \\
Std In: Entire Document
Std Out: Replace Document
Activation: Key Equivalent Cmd-S
The command above only strips whitespace. ie the file never gets saved. Following script should strip the whitespace and then save (Note: requires rb-appscript gem)
Save: Nothing
Command(s):
require 'rubygems' require 'appscript' class TextMate include Appscript def self.save_current doc = Application.by_name('TextMate').documents[0] if doc.modified.get doc_alias = MacTypes::Alias.path(doc.path.get) doc.save(:in => doc_alias) end end end doc_text = STDIN.read puts doc_text.gsub(/[\t ]+$/, '') TextMate.save_current
\
Save: Nothing \\
Save: Current File \\
Std In: Entire Document
Std Out: Replace Document
Activation: Key Equivalent Cmd-S
The command above only strips whitespace. ie the file never gets saved. Following script should strip the whitespace and then save (Note: requires rb-appscript gem)
Save: Nothing
Command(s):
require 'rubygems' require 'appscript' class TextMate include Appscript def self.save_current doc = Application.by_name('TextMate').documents[0] if doc.modified.get doc_alias = MacTypes::Alias.path(doc.path.get) doc.save(:in => doc_alias) end end end doc_text = STDIN.read puts doc_text.gsub(/[\t ]+$/, '') TextMate.save_current
\
Addendum to the addendum (works in FF2, FF3)
- Go to https://addons.mozilla.org/en-US/firefox/addon/4125 and install the current version of It's All Text!
- Once you've restarted Firefox, go to the prefs for It's All Text! and set the editor path to "/Applications/TextMate.app/Contents/Resources/mate".
Unclear - this would make temporary changes to the currently-loaded page's style? How sweeping do such edits need to be (that is, do they require TextMate)?
The command above only strips whitespace. ie the file never gets saved. Following script should strip the whitespace and then save (Note: requires rb-appscript gem)
Save: Nothing
Command(s):
require 'rubygems' require 'appscript' class TextMate include Appscript def self.save_current doc = Application.by_name('TextMate').documents[0] if doc.modified.get doc_alias = MacTypes::Alias.path(doc.path.get) doc.save(:in => doc_alias) end end end doc_text = STDIN.read puts doc_text.gsub(/[\t ]+$/, '') TextMate.save_current
Std In: Entire Document
Std Out: Replace Document
Activation: Key Equivalent Cmd-S
How to exclude files and folders from the Project Drawer]]
How to exclude files and folders from the Project Drawer
Example regex: to hide all compiled java classes (.class files), use this regex as a File Pattern: !\.class$
Example regex: to hide all compiled java classes (.class files), use this regex as a File Pattern: !\.class$
Steve King adds: You can do this globally instead of project-by-project by opening the Preferences window and going to "Advanced", "Folder References".
If you have problems with TextMate and sshfs (more sshfs than TextMate) crashing your computer, turn off the sshfs cache by adding 'cache=no,' to the above command before 'volname'. Later versions of sshfs can cache file changes for up to 20 seconds, which is often annoying.
If you have problems with TextMate and sshfs (more sshfs than TextMate) crashing your computer, turn off the sshfs cache by adding 'cache=no,' to the above command before 'volname'. Later versions of sshfs can cache file changes for up to 20 seconds, which is often annoying.
How to exclude files and folders from the Project Drawer]]
Textmate naturally doesn't display certain files and folders in the project view. For example, .svn and .git folders, and .pyc files.
1. Select the root folder of your project within the project drawer.
2. Click the 'i' button in the bottom right of the project drawer.
3. There are two text areas for regular expressions which control the files and folders displayed.
Example regex: to hide all compiled java classes (.class files), use this regex as a File Pattern: !\.class$
osascript, shell script, UTF-8 - Hans-Jörg Bibiko
osascript, shell script, UTF-8 - Hans-Jörg Bibiko
TextMate's internal encoding is UTF-8. This is also true for the Bundle Editor. But, how to deal with UTF-8 encoded text files or variables by writing a shell command in the Bundle Editor if osascript only expects data encoded in MacRoman?
Example:
- Read the UTF-8 encoded content of a file and insert it into an other document window without loosing the focus.
Before running command: Do nothing
Command(s):
# open/activate the target
mate ~/target.txt
# read the UTF-8 encode text coming from ~/test.txt
TXT=$(cat ~/test.txt)
# now comes the trick
cat <<-AS | iconv -f UTF-8 -t MACROMAN | osascript --
tell application "TextMate" to insert "$TXT"
tell application "System Events" to keystroke "\`" using (command down)
AS
Standard input: None
Standard output: Discard
osascript expects AppleScript commands encoded in MacRoman. This is simply done by using iconv. The actual UTF-8 data stored in $TXT are passed to osascript simply by bash shell's variable expansion facility.
If you have problems with TextMate crashing, try turning off the sshfs cache by adding 'cache=no,' to the above command before 'volname'.
If you have problems with TextMate and sshfs (more sshfs than TextMate) crashing your computer, turn off the sshfs cache by adding 'cache=no,' to the above command before 'volname'. Later versions of sshfs can cache file changes for up to 20 seconds, which is often annoying.
sshfs user@servername:/ ~/mnt/servername -oping_diskarb,volname=servername'
sshfs user@servername:/ ~/mnt/servername -o'ping_diskarb,volname=servername'
If you have problems with TextMate crashing, try turning off the sshfs cache by adding 'cache=no,' to the above command before 'volname'.
You can use *matewatch* to automatically track time spent in documents in Textmate. For more info go here
You can use *matewatch* to automatically track time spent in documents in Textmate. For more info go here
A new link for AS Dictionary integration: http://www.dirtystylus.com/blog/2007/04/24/enabling-actionscript-help-in-textmate/
Automatically backup your file each time you save - Michael Lehmkuhl
Decode a block of quoted-printable text - Michael Lehmkuhl
This command gives you a quick way to decode quoted-printable text, like if you copy it from the source of a multi-part email message, for example. download the command
matewatch
umount ~/mnt/servername
umount ~/mnt/servername
Automatically capitalize BibTeX search terms
One very useful command in the LaTeX bundle is "Citation based on current word/selection" (bound by default to Option-Escape). BibTeX entries, however, typically have all meaningful words capitalized, meaning that in order for "Citation based on current word/selection" to work properly, you must capitalize your search term, as the search functionality uses grep. If you'd like to be able to use this function in a case insensitive way, you can edit the command in the Bundle Editor so that it capitalizes your current word/selection before performing the BibTeX search. Just edit the fifth line in the command: instead of phrase = STDIN.read.chomp
, change it to phrase = STDIN.read.capitalize.chomp
. Now you should be able to use "Citation based on current word/selection" without having to worry about capitalizing your BibTeX search terms.
Case-insensitive BibTeX search terms
One very useful command in the LaTeX bundle is "Citation based on current word/selection" (bound by default to Option-Escape). BibTeX entries, however, typically have all meaningful words capitalized, meaning that in order for "Citation based on current word/selection" to work properly in its default configuration, you must capitalize your search term, as the search functionality uses grep. If you'd like to be able to use this function in a case-insensitive way, there are (at least) two options, each of which involves editing the command in the Bundle Editor. (1) You can make the search case-insensitive by adding a parameter to the grep command: edit the line that begins items = items.grep(/#{phrase}/)
so that it instead begins items = items.grep(/#{phrase}/i)
. (2) You can have TextMate capitalize your current word/selection before performing the BibTeX search. To do this, edit the fifth line in the command: instead of phrase = STDIN.read.chomp
, change it to phrase = STDIN.read.capitalize.chomp
. Note, though, that this second method will miss any search terms that aren't capitalized in your .bib file, so the first method is probably preferable. Either way, you should now be able to use "Citation based on current word/selection" without having to worry about capitalizing your BibTeX search terms.
Case insensitive BibTeX searches
One very useful command in the LaTeX bundle is "Citation based on current word/selection" (bound by default to Option-Escape). BibTeX entries, however, typically have all meaningful words capitalized, meaning that in order for "Citation based on current word/selection" to work properly, you must capitalize your search term, as the search functionality uses grep. If you'd like to be able to use this function in a case insensitive way, you can edit the command in the Bundle Editor so that it capitalizes your current word/selection before performing the BibTeX search. Just edit the fifth line in the command: instead of phrase = STDIN.read.chomp
, change it to phrase = STDIN.read.capitalize.chomp
. Now you should be able to use "Citation based on current word/selection" in a case insensitive way, without having to worry about capitalizing your BibTeX search terms.
Automatically capitalize BibTeX search terms
One very useful command in the LaTeX bundle is "Citation based on current word/selection" (bound by default to Option-Escape). BibTeX entries, however, typically have all meaningful words capitalized, meaning that in order for "Citation based on current word/selection" to work properly, you must capitalize your search term, as the search functionality uses grep. If you'd like to be able to use this function in a case insensitive way, you can edit the command in the Bundle Editor so that it capitalizes your current word/selection before performing the BibTeX search. Just edit the fifth line in the command: instead of phrase = STDIN.read.chomp
, change it to phrase = STDIN.read.capitalize.chomp
. Now you should be able to use "Citation based on current word/selection" without having to worry about capitalizing your BibTeX search terms.
LaTeX
Case insensitive BibTeX searches
One very useful command in the LaTeX bundle is "Citation based on current word/selection" (bound by default to Option-Escape). BibTeX entries, however, typically have all meaningful words capitalized, meaning that in order for "Citation based on current word/selection" to work properly, you must capitalize your search term, as the search functionality uses grep. If you'd like to be able to use this function in a case insensitive way, you can edit the command in the Bundle Editor so that it capitalizes your current word/selection before performing the BibTeX search. Just edit the fifth line in the command: instead of phrase = STDIN.read.chomp
, change it to phrase = STDIN.read.capitalize.chomp
. Now you should be able to use "Citation based on current word/selection" in a case insensitive way, without having to worry about capitalizing your BibTeX search terms.
--Nick Fleisher
You can use *matewatch* to automatically track time spent in documents in Textmate. For more info go here: http://blog.ardes.com/articles/2007/09/14/textmate-user-time-tracking-for-free-matewatch
You can use *matewatch* to automatically track time spent in documents in Textmate. For more info go here
Now on the commandline on my laptop, I go to any file in ~/mnt/servername/ and do: mate <filename> and I can just add files to a projectdrawer in textmate. Best of all is that you do not need to prepare anything on your server if it is already running ssh.
Now on the commandline on my laptop, I go to any file in ~/mnt/servername/ and do: mate <filename> and I can just add files to a projectdrawer in textmate. Best of all is that you do not need to prepare anything on your server if it is already running ssh.
If you are done, unmount the Volume by clicking on the regular eject icon in Finder or type the following in your Terminal:
umount ~/mnt/servername
cat <&0 >/tmp/saf_tmp.html >&1
\\
tee /tmp/saf_tmp.html
\\
Preview in Safari - Yvan BARTHÉLEMY
If you want a JavaScript aware previewer, you probably want to use Safari or Firefox to preview your page rather than the built-in previewer.
First, copy this shell script somewhere on your filesystem
#!/bin/bash --posix
cat <&0 >/tmp/saf_tmp.html >&1
osascript -e "tell application \"Safari\" to open location \"file:///tmp/saf_tmp.html\""
Of course you might replace Safari with any browser of your choice, and modify this script to allow choosing browser using a command-line argument.
Then, open the TextMate Web Preview, check the checkbox : Pipe Text trough,
then paste 'sh' followed with the path to your script (e.g. 'sh ~/Documents/script/browser.sh')
If you're switching to TextMate from BBEdit and you do a lot of HTML content creation, you may be bummed to find that the "wrap selection in open/close tags" bundle item wraps the whole selection in p, rather than detecting each individual paragraph, as BBEdit does. To make this work as expected, open the Bundle editor. Select the bundle "Wrap each selected Line in Open/Close Tag" and duplicate it. Rename it something like "Wrap paragraphs." Edit the duplicate to use p rather than li. Give it key equivalent (I use Cmd-P, since this is such a common action). -- S Hacker
If you're switching to TextMate from BBEdit and you do a lot of HTML content creation, you may be bummed to find that the "wrap selection in open/close tags" bundle item wraps the whole selection in p, rather than detecting each individual paragraph, as BBEdit does. To make this work as expected, open the Bundle editor. Select the bundle "Wrap each selected Line in Open/Close Tag" and duplicate it. Rename it something like "Wrap paragraphs." Edit the duplicate to use p rather than li. Give it a key equivalent (I use Cmd-P, since this is such a common action). -- S Hacker
If you're switching to TextMate from BBEdit and you do a lot of HTML content creation, you may be bummed to find that the "wrap selection in open/close tags" bundle item wraps the whole selection in p, rather than detecting each individual paragraph, as BBEdit does. To make this work as expected, open the Bundle editor. Select the bundle "Wrap each selected Line in Open/Close Tag" and duplicate it. Edit the duplicate to use p rather than li. Give it key equivalent (I use Cmd-P, since this is such a common action). -- S Hacker
If you're switching to TextMate from BBEdit and you do a lot of HTML content creation, you may be bummed to find that the "wrap selection in open/close tags" bundle item wraps the whole selection in p, rather than detecting each individual paragraph, as BBEdit does. To make this work as expected, open the Bundle editor. Select the bundle "Wrap each selected Line in Open/Close Tag" and duplicate it. Rename it something like "Wrap paragraphs." Edit the duplicate to use p rather than li. Give it key equivalent (I use Cmd-P, since this is such a common action). -- S Hacker
Wrap All Paragraphs with p
If you're switching to TextMate from BBEdit and you do a lot of HTML content creation, you may be bummed to find that the "wrap selection in open/close tags" bundle item wraps the whole selection in p, rather than detecting each individual paragraph, as BBEdit does. To make this work as expected, open the Bundle editor. Select the bundle "Wrap each selected Line in Open/Close Tag" and duplicate it. Edit the duplicate to use p rather than li. Give it key equivalent (I use Cmd-P, since this is such a common action). -- S Hacker
The following link is broken, if someone has another resource, please post it. \\
The following two links are also broken, if someone has another resource, please post it. \\
How to edit remote files using macfuse and sshfs - Christian Tan
One major annoyance for me was being unable to use textmate project management for files on my server. I used to use cyberduck with textmate, which works ok, but this one is more conveniant:
Install macfuse
Mount your remote server using sshfs:
sshfs user@servername:/ ~/mnt/servername -oping_diskarb,volname=servername'
Now on the commandline on my laptop, I go to any file in ~/mnt/servername/ and do: mate <filename> and I can just add files to a projectdrawer in textmate. Best of all is that you do not need to prepare anything on your server if it is already running ssh.
PHP Tricks
PHP code completion - Ian White
I've created a couple of scripts that give the effect of code completion. Description and download at http://ian.ardes.com/phpcc
PHP documentation command for selected word:
Change the tabsize of soft-tab files - Arnar Birgisson
This python command takes every 3 spaces at the beginning of a line and adds one more, effectively moving from 3sp soft-tabs to 4sp ones. Change the numbers at will, although you need to change it more if you want to decrease the tabsize.
Input: Selected Text or Document
Output: Replace Selected Text
- !/usr/bin/env python
import os import re from sys import stdout, stdin, exit
r = re.compile('^( +)')
for line in stdin:
m = r.match(line) if m: c = len(m.group(1)) stdout.write(' ' * (c/3)) stdout.write(line)=]
PHP Tricks
PHP code completion - Ian White
I've created a couple of scripts that give the effect of code completion. Description and download at http://ian.ardes.com/phpcc
PHP documentation command for selected word:
[=
Now every time you save with Cmd-S, TM will prompt you with a dialog box asking for a log message and checkin the file, and recheck it out. If you include the $Id$ and $Log$ tags you can see the information about the revision and pervious log messages.
Now every time you save with Cmd-S, TM will prompt you with a dialog box asking for a log message and checkin the file, and recheck it out. If you include the $Id$ and $Log$ tags you can see the information about the revision and pervious log messages.
Automatically strip trailing whitespace each time you save - Albert Davidson Chou
In every editor I use that has a setting to strip trailing whitespace on save, I enable it. TextMate doesn't have one, but it does have a command to strip trailing whitespace, so you can make a copy of that command and set its key equivalent to Cmd-S to get the same functionality:
Save: Nothing
Command(s): perl -pe 's/[\t ]+$//g'
Std In: Entire Document
Std Out: Replace Document
Activation: Key Equivalent Cmd-S
Send Front Files to BBEdit "Find Differences..." - Provided by Michael Lehmkuhl
Finds the two frontmost TextMate documents that have valid paths and sends them to BBEdit for diff'ing.
Save: Nothing
Command(s): /usr/bin/osascript -e '
set file1 to ""
set file2 to ""
tell application "TextMate"
repeat with doc in documents
try
set file1 to the path of doc
on error
set file1 to ""
end try
end repeat
repeat with doc in documents
try
if the path of doc is not file1 then
set file2 to the path of doc
end if
on error
set file2 to ""
end try
end repeat
set okgo to false
try
if (file1 is not "") and (file2 is not "") then
set okgo to true
end if
end try
end tell
if okgo then
tell application "BBEdit"
set r to compare (POSIX file file1) against (POSIX file file2)
if differences found of r is false then
return reason for no differences of r
else
activate
end if
end tell
else
return "At least two saved files must be open in TextMate to run this command."
end if
';
Input: None
Output: Show as Tool Tip
Send Front Files to BBEdit "Find Differences..." - Provided by Michael Lehmkuhl
Finds the two frontmost TextMate documents that have valid paths and sends them to BBEdit for diff'ing.
Save: Nothing
Command(s): /usr/bin/osascript -e '
set file1 to ""
set file2 to ""
tell application "TextMate"
repeat with doc in documents
try
set file1 to the path of doc
on error
set file1 to ""
end try
end repeat
repeat with doc in documents
try
if the path of doc is not file1 then
set file2 to the path of doc
end if
on error
set file2 to ""
end try
end repeat
set okgo to false
try
if (file1 is not "") and (file2 is not "") then
set okgo to true
end if
end try
end tell
if okgo then
tell application "BBEdit"
set r to compare (POSIX file file1) against (POSIX file file2)
if differences found of r is false then
return reason for no differences of r
else
activate
end if
end tell
else
return "At least two saved files must be open in TextMate to run this command."
end if
';
Input: None
Output: Show as Tool Tip
There is an "Insert color…" command in the CSS bundle that surely works also for other scopes. Selecting a color hex code will bring up a color selector with that color with which one can change the color. Clicking okay will replace the old hex code. Besides the occasional beach ball it is working fine for me. --anarchitect
There is an "Insert color…" command in the CSS bundle that surely works also for other scopes. Selecting a color hex code and calling upon Cmd-Shift-C will bring up a color selector with that color with which one can change the color. Clicking okay will replace the old hex code. Besides the occasional beach ball it is working fine for me. --anarchitect
There is an "Insert color…" command in the CSS bundle that surely works also for other scopes. Selecting a color hex code will bring up a color selector with that color with which one can change the color. Clicking okay will replace the old hex code. Besides the occasional beach ball it is working fine for me. --anarchitect
Applescript to open the current file in an arbitrary application - Jeroen van der Ham
Perhaps this is peanuts for people who know Applescript, but I searched for a couple of hours before I could find how to use Unix-style filepaths in an applescript:
Finder Toolbar Icon - William Scott
Save this as an AppleScript application, give it a nice icon, and put it in the Finder toolbar. Clicking it opens a TextMate project corresponding to the directory displayed in the Finder.
osascript -e "tell application \"Preview\"
activate open POSIX file \"${TM_FILEPATH\"
end tell"
try
tell application "Finder" to set the source_folder to (folder of the front window)
on error -- no open folder windows
set the source_folder to path to desktop folder as alias set source to source_folder as alias
end try
if kind of source_folder = "folder" then
set source to source_folder as alias set ThePath to (POSIX path of the source as string)
else
set the source_folder to the folder of source_folder set source to source_folder as alias set ThePath to (POSIX path of source as string) set the result to ThePath
end if set TheCommand to "open -a TextMate " & quoted form of ThePath do shell script TheCommand
This command be useful for example when editing .tex
files, running latex
over it and previewing the resulting PDF in one go. In which case you need to replace the extension as well, so then you should use the line below.
Applescript to open the current file in an arbitrary application - Jeroen van der Ham
Perhaps this is peanuts for people who know Applescript, but I searched for a couple of hours before I could find how to use Unix-style filepaths in an applescript:
open POSIX file \"${TM_FILEPATH%/.tex/.pdf}\"
osascript -e "tell application \"Preview\"
activate open POSIX file \"${TM_FILEPATH\"
end tell"
This didn't work for me. I used:
This command be useful for example when editing .tex
files, running latex
over it and previewing the resulting PDF in one go. In which case you need to replace the extension as well, so then you should use the line below.
open POSIX file \"${TM_FILEPATH%.tex}.pdf\"
open POSIX file \"${TM_FILEPATH%/.tex/.pdf}\"
This didn't work for me. I used:
open POSIX file \"${TM_FILEPATH%.tex}.pdf\"
write text "cd '$TM_PATH'; clear; pwd"
\\
write text "cd '$TM_DIRECTORY'; clear; pwd"
\\
(You guys are smart enough to work out my email address from that)
(You guys are smart enough to work out my email address from that)
Applescript
Open iTerm Here - William Scott
Opens an iTerm tabbed window in the current file's directory.
Before running command: Do nothing
Command(s): osascript <<EOF
tell application "iTerm"
make new terminal
tell the first terminal
activate current session
launch session "Default Session"
tell the last session
write text "cd '$TM_PATH'; clear; pwd"
end tell
end tell
end tell
EOF
Standard input: None
Standard output: Discard
Update I have updated M.Spreij's pdoc to further refine this great functionality. You can grab the source here.
Update: I have updated M.Spreij's pdoc to further refine this great functionality. You can grab the source here.
Update I have updated M.Spreij's pdoc to further refine this great functionality. You can grab the source here.
http://www.monokai.nl/asDev/
http://www.monokai.nl/blog/2006/07/14/using-textmate-mtasc-and-xtrace-to-build-flash-projects-in-mac-osx/
THETIME=`php -r 'print date('his');'`
\\
THETIME=`php -r 'print date('His');'`
\\
Using Textmate, Mtasc and Xtrace to build Flash projects:
Using Textmate, Mtasc and Xtrace to build Flash projects:
http://www.monokai.nl/asDev/
Activation: Key Equivalent Ctrl-Shft-A
Activation: Key Equivalent Ctrl-Shft-A
Any queries contact my gmail.com account. avenjamin is the username. (You guys are smart enough to work out my email address from that)
[=
[=
Subversion Checkout
Not sure how useful this is to other people. But I have written a command for the Subversion bundle that lets me do a checkout. It asks for the url and then where to save it. Progress bar appears while checkout happens. Once done, then opens project in TextMate. The url format I have for my host is svn-ssh:// not sure how similar that is for other users.
Save: Nothing
Command(s):
# Setup Dialog asking for host url=$(CocoaDialog inputbox \ --title "Checkout..." \ --informative-text "Enter the host:" \ --text "svn+ssh://" \ --button1 "Checkout" \ --button2 "Cancel") # If user canceled exit. [[ $( (tail -r <<<"$url") | tail -n1) == "2" ]] && \ exit_discard # url contains the url entered url=$(tail -n1 <<<"$url") # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # # Setup Dialog asking where to save location=$(CocoaDialog fileselect \ --text "Select Folder to Checkout to" \ --select-only-directories \ --with-directory "~/") # If user canceled exit. [[ $( (tail -r <<<"$location") | tail -n1) == "2" ]] && \ exit_discard # location contains the location selected location=$(tail -n1 <<<"$location") res=$({ cd $location svn checkout --quiet $url } > >(CocoaDialog progressbar \ --indeterminate \ --title "Checking Out" \ --text "Please wait, this could take some time")) project=`basename $url` open -b com.macromates.TextMate "$location/$project"
Std In: None
Std Out: Insert as Snippet
Activation: Key Equivalent Ctrl-Shft-A
- Go into the extension preferences (Firefox->Tools->Extension Manager->mozex->Preferences). In the "Textarea" tab put:
- Go into the extension preferences (Firefox->Tools->Extension Manager->mozex->Preferences). In the "Textarea" tab put: "/usr/bin/mate -w %t" (or whichever path you chose when you created the symbolic link to mate through TextMate).
In OS X: In the "Textarea" tab put:
(If your TextMate application is not in the main applications folder, you'll need to enter the path to where you have it)
- Go into the extension preferences (Firefox->Tools->Extension Manager->mozex->Preferences) and in the textarea set the command to: "/usr/bin/mate -w %t" (or whichever path you chose when you created the symbolic link to mate through TextMate).
- You can now edit textareas by right clicking and choosing MozEx ->Edit textarea. The text will open up in TextMate which you can then edit. When you have finished and saved the file, you just need to click in the textarea for the contents to update to the changes you have made.
- Go into the extension preferences (Firefox->Tools->Extension Manager->mozex->Preferences). In the "Textarea" tab put:
/Applications/TextMate.app/Contents/Resources/mate -w %t
(If your TextMate application is not in the main applications folder, you'll need to enter the path to where you have it)
You can now edit textareas by right clicking and choosing MozEx ->Edit textarea. The text will open up in TextMate which you can then edit. When you have finished and saved the file, you just need save the file or, click in the textarea for the contents to update with the changes you made in TextMate.
Is there any way to persuade TextMate to work with the CSS Editor (in the Web Developer extension) ?
Is there any way to persuade this to work with the CSS Editor (in the Web Developer extension) ?
Is there any way to persuade TextMate to work with the CSS Editor (in the Web Developer extension) ?
Automatically back you files to a RCS repository each time you save. - Gautam Dey
This based on the Backup On Save tip. However, I wanted my backup to use RCS, which comes pre-installed on the OS X. (At least with Tiger. Don't know about the older versions.) So, I wrote up this command, at current it creates an RCS directory in the same folder as the file, and check's in the file to that directory. It also rechecks out the file. following command:
Save: Current File
Command(s):
# Check to see if the directory exists, if not create it. [[ -d RCS ]] || mkdir RCS # Ask for a Log message. res=$(CocoaDialog inputbox \ --title "Message for rcs" \ --informative-text "Message for rcs:" \ --button1 "Okay" \ --button2 "Cancel") # If user canceled exit. [[ $( (tail -r <<<"$res") | tail -n1) == "2" ]] && \ exit_discard res=$(tail -n1 <<<"$res") ci -l -m"$res" $TM_FILEPATH
Std In: None
Std Out: Show as Tooltip
Activation: Key Equivalent Cmd-S
Now every time you save with Cmd-S, TM will prompt you with a dialog box asking for a log message and checkin the file, and recheck it out. If you include the $Id$ and $Log$ tags you can see the information about the revision and pervious log messages.
This can be done by using iconv
, see this letter for an example bundle which add new re-open with encoding commands via a bundle.
This can be done by using iconv
, see this letter for an example bundle which adds new re-open with encoding commands through a bundle.
Instructions are in this letter from the mailing list.
Access Color Palette
If you have Interface Builder (part of the dev tools) you can open up TextMate's MainMenu.nib and create a menu item that opens the color window. It's easiest to open a "new" IB nib selecting the "cocoa application" template, go copy the menu item you want "show colors" and then paste it into TextMate's menu nib. Save and open TextMate and test it out. -- Tim Martin
Or you add a "du -hd 0 "$TM_BACKUP_DIR"" and output to a tooltip to keep track of the size of you backupdir.
Integration with Thunderbird
You can use TextMate to edit emails from Thunderbird.
- Get a copy of the External Editor extension from http://globs.org/articles.php?lng=en&pg=2 and install it from the Tools -> Extensions dialog in Thunderbird
- Follow the installation instructions on the page
- Set the editor to /usr/bin/mate -w in the extension preferences
Addendum to integrating with Firefox 1.5
- Go to http://mozex.mozdev.org/development.html and download the (currently development version) MozEx 2.0 and install it into Firefox.
- Go into the extension preferences (Firefox->Tools->Extension Manager->mozex->Preferences) and in the textarea set the command to: "/usr/bin/mate -w %t" (or whichever path you chose when you created the symbolic link to mate through TextMate).
- You can now edit textareas by right clicking and choosing MozEx ->Edit textarea. The text will open up in TextMate which you can then edit. When you have finished and saved the file, you just need to click in the textarea for the contents to update to the changes you have made.
How to extend an existing bundle
If you want to extend a language grammar and/or change the behavior of one bundle without actually modifying that bundle itself (i.e. you would like to keep your changes separate from the bundle's original code) you will need to do the following:
- create a new bundle
- create a new language grammar. give it a scope name of your.original.scope.someextension:
e.g. scopeName = 'text.plain.mail.custom'; - add your own language grammar, possibly overriding stuff that is in the bundle
- at the end of the language grammar include the original bundle like this:
{ include = 'text.plain.mail'; },
- [[#HTMLColor | Drop Colorcodes From Pref's Colorwheel]
- [[#HTMLColor | Drop Colorcodes From Pref's Colorwheel]
- #Reformat HTML-TextMate
PHP Tricks
PHP code completion - Ian White
I've created a couple of scripts that give the effect of code completion. Description and download at http://ian.ardes.com/phpcc
PHP documentation command for selected word:
Change Leading Spaces To Tabs - M Spreij
Bit of PHP code that does what the title says.. you can change the number of spaces one tab will replace. Leftover spaces will stay put.
Input: Selected Text
Output: Replace Selected Text
- !/usr/bin/php
<?php $fetch = fread(STDIN, 100); if (! strlen($fetch)) {
return;
}
- set this to what you want
$tablength = 2;
$data = $fetch;
while (strlen($fetch)) {
$fetch = fread(STDIN, 1000); $data .= $fetch;
}
$output = ''; foreach(explode("\n", $data) as $line) {
$len = floor(strspn($line, " ") / $tablength); $output .= str_repeat("\t", $len) . substr($line, $tablength * $len) . "\n";
} echo substr($output, 0, -1); ?>=]
PHP Tricks
PHP code completion - Ian White
I've created a couple of scripts that give the effect of code completion. Description and download at http://ian.ardes.com/phpcc
PHP documentation command for selected word:
[=
Standard input: Selected Text
Standard input: None
PHP Project Functions - "Dion Almaer"
Goes through the project directory and groks out all functions. If you select some text it will narrow it to that.
Before running command: Nothing Command(s): grep -E -n -r --include=\*.php --exclude=.svn "function ${TM_SELECTED_TEXT:-$TM_CURRENT_WORD}\w+\s*\(" ${TM_PROJECT_DIRECTORY:-$TM_DIRECTORY} Standard input: Selected Text Standard output: Show in separate window Pattern: ^(.+):(\d+):(.*)$ Format String: $1, line $2: $3 File Register: 1 Line: 2
- Run preg_replace to take variable declarations
- Run preg_replace_callback to take variable declarations
http://froderman.com/index.php?option=com_content&task=view&id=25&Itemid=48
Create Getters/Setters - Jason Froderman
- Save: Nothing - Command: ## Run preg_replace to take variable declarations ## and create getter/setter method php -r 'echo preg_replace_callback("|(\w+) (\w+) (\w+):(\w+);|", create_function("\$matches","return \"\npublic function get\".ucfirst(\$matches[3]).\"():\".\$matches[4].\" {\n\treturn \".\$matches[3].\"; \n}\n\n\".\$matches[1].\" function set\".ucfirst(\$matches[3]).\"(\".\$matches[3].\":\".\$matches[4].\"):Void {\n\tthis.\".\$matches[3].\" = \".\$matches[3].\";\n}\";"), file_get_contents("/dev/stdin") );'; - Input: Selected text - Output: Insert as text
Input backslash character - OGURA Toshiyuki a.k.a. OGURADIO
I've created a document that may help Japanese keymap users to type in backslash character in TextMate documents. Description at http://www.oguradio.com/blog/archives/2005/09/textmate.html
Sum all numbers following a '$', useful for adding costs - Jim Bagrow
Sum all numbers following a '$', useful for adding costs - Jim Bagrow
more appropriate. Feel free to improve! Modification to other currency symbols should be obvious.
- Update: TM has a Math bundle, which can be used pretty much to do exactly what this tip does. I think it's useful to keep this tip around for the python/regex example of matching to the dollar signs. -- Jim Bagrow
more appropriate. Feel free to improve!
Find class or method definition
Change the version of python PyMate uses
- In the "Advanced" pane of TextMate preferences, choose the "Shell Variables" tab. - Create a new shell variable by clicking the + symbol. - Set the variable to TM_PYTHON - Set the value to the full path (doesn't work with /usr/bin/env python entries).
LaTeX Tips
Enabling PDFsync
Here's what I needed to go through to get PDFsync working on my machine. YMMV. I'm using texniscope as the viewer.
- Download pdfsync. Following the download page, drag the necessary files to your ~/Library/ directory. The texmf folder didn't exist in my library so I just dragged the whole thing over.
- Specify the LaTeX Viewer in TM's prefs. Go to the Advanced preference pane and click on the Shell Variables tab. Add a new variable called TM_LATEX_VIEWER with Value TeXniscope.
- Tell TeXniscope to use TM as the editor. Go to TeXniscope's preferences and click the paths tab. Set Editor command to open and Editor arguments to "txmt://open?url=file://%file&line=%line" (including the quotes).
That should do it. Don't forget to add \usepackage{pdfsync} in the latex document to tell it to make the necessary sync data! Thanks to Haris Skiadas for explaining most of this in his screencast. Hope this helps!
Tricks for Japanese users
Input backslash character - OGURA Toshiyuki a.k.a. OGURADIO
I've created a document that may help Japanese keymap users to type in backslash character in TextMate documents. Description at http://www.oguradio.com/blog/archives/2005/09/textmate.html
You can input a backslash on a Japanese keyboard by holding option and pressing the yen (Â¥) key.
- get mozex-helper from http://www.noctua.org.uk/paul/software/, read the documentation and install it by following the detailed instructions you'll find there (you need a C compiler);
set editor_command to"/usr/bin/mate -w %s"
- get mozex-helper from http://www.noctua.org.uk/paul/software/, read the documentation and install it;
set editor_command to "/usr/bin/mate -w %s"
If you are using FireFox 1.5 It's much simpler. All you have to do is
- Get mozex from https://nic-nac-project.de/~kaosmos/mozex107-en.html and install it by dragging the .xpi onto the browser
- in Firefox->Tools->Extension Manager->mozex->Preferences set up the temp directory to
/tmp/
and the text area editor to'/usr/bin/mate -w %t
- done, you can edit text areas with TextMate by right-clicking->mozex->Edit textarea
--Xian
Java
Using PMD
First, download and unpack PMD from http://pmd.sf.net. Unpack it wherever you want. Create a new command called 'PMD' with 'Entire Input' as the input and 'Show as HTML' for output. The command is:
<pmd-dir>/bin/pmd.sh $TM_FILEPATH html <comma separated rules>
Now, run the command on a java file and look at your pretty list of errors. You can read up on all the rules at the link above.
Using Checkstyle
Download and unpack Checkstyle from http://checkstyle.sf.net/. If you feel like grabbing the src release that's fine, but the top release works great. You'll also need an XSLT tool for prettily viewing output. I got it all in a nice package from http://www.explain.com.au/oss/libxml2xslt.html. The instructions on the page are good, the frameworks go in /Library/Frameworks or wherever, and the tools go somewhere in your path. (Like /usr/local/bin/)
Got all that? Good. Put this in a new command in TextMate:
java -classpath <checkstyle-dir>/checkstyle-all-4.1.jar com.puppycrawl.tools.checkstyle.Main -c <full-path-to-rules-file> -f xml $TM_FILEPATH > /tmp/checkstyle-output.xml ; xsltproc <checkstyle-dir>/contrib/checkstyle-noframes.xsl /tmp/checkstyle-output.xml
(I can't get line breaks in the green box... am I slow?)
If you don't feel like going through the XSLT stuff, you can replace '-f xml' with '-f text' and delete everything after $TM_FILEPATH.
-- Kyle Brett
If you are using FireFox 1.5 It's much simpler. All you have to do is
- Get mozex from https://nic-nac-project.de/~kaosmos/mozex107-en.html and install it by dragging the .xpi onto the browser
- in Firefox->Tools->Extension Manager->mozex->Preferences set up the temp directory to
/tmp/
and the text area editor to'/usr/bin/mate -w %t
- done, you can edit text areas with TextMate by right-clicking->mozex->Edit textarea
--Xian
ASCII
Center Text
The following command is useful for centering ASCII text:
echo "$TM_SELECTED_TEXT" | python -c "import sys; print '\n'.join([x.strip().center(80).rstrip() for x in sys.stdin.readlines()])"
Find class or method definition
Ruby/Python
Find class or method definition
Change the version of python PyMate uses
- In the "Advanced" pane of TextMate preferences, choose the "Shell Variables" tab. - Create a new shell variable by clicking the + symbol. - Set the variable to TM_PYTHON - Set the value to the full path (doesn't work with /usr/bin/env python entries).
- get mozex-helper from http://www.noctua.org.uk/paul/software/, read the documentation and install it;\\
- get mozex-helper from http://www.noctua.org.uk/paul/software/, read the documentation and install it by following the detailed instructions you'll find there (you need a C compiler);\\
--I can't get this working, with Firefox 1.5.0.1. The call to TextMate produces an error about %s
being unknown. This is odd, since I can type /usr/bin/mate -w %s
in the shell and it works. Any advice from anywone? Dan Kelley
--I can't get this working, with Firefox 1.5.0.1. The call to TextMate produces an error about %s
being unknown. This is odd, since I can type /usr/bin/mate -w %s
in the shell and it works. Any advice from anywone? [[Profiles/Dan Kelley]
--I can't get this working, with Firefox 1.5.0.1. The call to TextMate produces an error about %s
being unknown. This is odd, since I can type /usr/bin/mate -w %s
in the shell and it works. Any advice from anywone? Dan Kelley
--I can't get this working, with Firefox 1.5.0.1. The call to TextMate produces an error about %s
being unknown. This is odd, since I can type /usr/bin/mate -w %s
in the shell and it works. Any advice from anywone? [[Profiles/Dan Kelley]
set editor_command to "/usr/bin/mate -w %s"
set editor_command to "/usr/bin/mate -w %s"
java -classpath <checkstyle-dir>/checkstyle-all-4.1.jar com.puppycrawl.tools.checkstyle.Main -c <full-path-to-rules-file> -f xml $TM_FILEPATH > /tmp/checkstyle-output.xml
java -classpath <checkstyle-dir>/checkstyle-all-4.1.jar com.puppycrawl.tools.checkstyle.Main -c <full-path-to-rules-file> -f xml $TM_FILEPATH > /tmp/checkstyle-output.xml ;
(I can't get line breaks in the green box... am I slow?)
Java
Using PMD
First, download and unpack PMD from http://pmd.sf.net. Unpack it wherever you want. Create a new command called 'PMD' with 'Entire Input' as the input and 'Show as HTML' for output. The command is:
<pmd-dir>/bin/pmd.sh $TM_FILEPATH html <comma separated rules>
Now, run the command on a java file and look at your pretty list of errors. You can read up on all the rules at the link above.
Using Checkstyle
Download and unpack Checkstyle from http://checkstyle.sf.net/. If you feel like grabbing the src release that's fine, but the top release works great. You'll also need an XSLT tool for prettily viewing output. I got it all in a nice package from http://www.explain.com.au/oss/libxml2xslt.html. The instructions on the page are good, the frameworks go in /Library/Frameworks or wherever, and the tools go somewhere in your path. (Like /usr/local/bin/)
Got all that? Good. Put this in a new command in TextMate:
java -classpath <checkstyle-dir>/checkstyle-all-4.1.jar com.puppycrawl.tools.checkstyle.Main -c <full-path-to-rules-file> -f xml $TM_FILEPATH > /tmp/checkstyle-output.xml xsltproc <checkstyle-dir>/contrib/checkstyle-noframes.xsl /tmp/checkstyle-output.xml
If you don't feel like going through the XSLT stuff, you can replace '-f xml' with '-f text' and delete everything after $TM_FILEPATH.
-- Kyle Brett
That should do it. Don't forget to add \usepackage{pdfsync} in the latex document to tell it to make the necessary sync data! Thanks to Haris Skiadas for explaining most of this in his screencast. Hope this helps!
That should do it. Don't forget to add \usepackage{pdfsync} in the latex document to tell it to make the necessary sync data! Thanks to Haris Skiadas for explaining most of this in his screencast. Hope this helps!
- Tell TeXniscope to use textmate when syncing. Go to TeXniscope's preferences and click the paths tab. Set Editor command to open and Editor arguments to "txmt://open?url=file://%file&line=%line" (including the quotes).
- Tell TeXniscope to use TM as the editor. Go to TeXniscope's preferences and click the paths tab. Set Editor command to open and Editor arguments to "txmt://open?url=file://%file&line=%line" (including the quotes).
Sum all numbers following a '$', useful for adding costs - Jim Bagrow
Sum all numbers following a '$', useful for adding costs - Jim Bagrow
more appropriate. Feel free to improve!
more appropriate. Feel free to improve! Modification to other currency symbols should be obvious.
- Update: TM has a Math bundle, which can be used pretty much to do exactly what this tip does. I think it's useful to keep this tip around for the python/regex example of matching to the dollar signs. -- Jim Bagrow
LaTeX Tips
Enabling PDFsync
Here's what I needed to go through to get PDFsync working on my machine. YMMV. I'm using texniscope as the viewer.
- Download pdfsync. Following the download page, drag the necessary files to your ~/Library/ directory. The texmf folder didn't exist in my library so I just dragged the whole thing over.
- Specify the LaTeX Viewer in TM's prefs. Go to the Advanced preference pane and click on the Shell Variables tab. Add a new variable called TM_LATEX_VIEWER with Value TeXniscope.
- Tell TeXniscope to use textmate when syncing. Go to TeXniscope's preferences and click the paths tab. Set Editor command to open and Editor arguments to "txmt://open?url=file://%file&line=%line" (including the quotes).
That should do it. Don't forget to add \usepackage{pdfsync} in the latex document to tell it to make the necessary sync data! Thanks to Haris Skiadas for explaining most of this in his screencast. Hope this helps!
Tricks for Japanese users
Input backslash character - OGURA Toshiyuki a.k.a. OGURADIO
I've created a document that may help Japanese keymap users to type in backslash character in TextMate documents. Description at http://www.oguradio.com/blog/archives/2005/09/textmate.html
You can input a backslash on a Japanese keyboard by holding option and pressing the yen (Â¥) key.
PHP Tricks
PHP code completion - Ian White
I've created a couple of scripts that give the effect of code completion. Description and download at http://ian.ardes.com/phpcc
PHP documentation command for selected word:
Look up the current word at www.dict.org. - johnatl
The word does not have to be selected.
You will need to install the dict command. This is simple with port from DarwinPorts. Once dict is installed, create a New Command with the following:
Before running command: do nothing Command(s): open http://nl.php.net/$TM_CURRENT_WORD Standard in/output: None/Discard
Save: Nothing Command(s): dict "$TM_CURRENT_WORD" Input: Selected Text or Word Output: Show as Tool Tip
PHP Documentation - M Spreij
I created a PHP shell script that will get just the first few lines (function name, php versions and syntax format) from http://php.net, it was a snap to tie it to a tooltip command as well:
I use Ctrl+Help as the Key Equivalent.
PHP Tricks
PHP code completion - Ian White
I've created a couple of scripts that give the effect of code completion. Description and download at http://ian.ardes.com/phpcc
PHP documentation command for selected word:
Command(s): ~/bin/pdoc $TM_CURRENT_WORD Standard input: Selected Text Standard output: Show as tooltip
Command(s): open http://nl.php.net/$TM_CURRENT_WORD Standard in/output: None/Discard
Example image
And this opens the doc page in the browser:
PHP Documentation - M Spreij
I created a PHP shell script that will get just the first few lines (function name, php versions and syntax format) from http://php.net, it was a snap to tie it to a tooltip command as well:
Command(s): open http://php.net/$TM_CURRENT_WORD Standard in/output: None/Discard
Command(s): ~/bin/pdoc $TM_CURRENT_WORD Standard input: Selected Text Standard output: Show as tooltip
Example image
And this opens the doc page in the browser:
Before running command: do nothing Command(s): open http://php.net/$TM_CURRENT_WORD Standard in/output: None/Discard
Find class or method definition
- Input: Selected Text or Word - Command: grep "[def|class] $TM_SELECTED_TEXT" -l -n -d recurse $TM_PROJECT_DIRECTORY - Output: Show as tooltip - Activation: Key Equivalent: Cmd+F1
You can input a backslash on a Japanese keyboard by holding option and pressing the yen (Â¥) key.
Description at http://www.oguradio.com/blog/archives/2005/09/textmate.html
Description at http://www.oguradio.com/blog/archives/2005/09/textmate.html
Integration with Firefox
You can use TextMate to edit text areas (forms) in Firefox. This comes in handy when you have to work a lot with CMS software that is only programmable via web interfaces.
- get a hacked-up version of mozex from https://nic-nac-project.de/~kaosmos/mozex107-en.html and install it by dragging the .xpi onto the browser
- get mozex-helper from http://www.noctua.org.uk/paul/software/, read the documentation and install it;
set editor_command to "/usr/bin/mate -w %s" - in Firefox->Tools->Extension Manager->mozex->Preferences set up the temp directory according to your setting in "mozex-helper.py" and the text area editor to the "mozex-helper" wrapper
- done, you can edit text areas with TextMate by right-clicking->mozex->Edit textarea
Automatically backup your file each time you save - Michael Lehmkuhl
A command to enable automatic backup copies of edited files, a la BBEdit's "Make Backup Before Saving" preference.
The Setup: Set up a TM_BACKUP_DIR environment variable in the Advanced / Shell Variables
section of the TM preferences. Set it to the directory where you'd like your backups to be saved.
Use the full path (i.e., /Users/michael/Documents rather than ~/Documents).
Save: Current File
Command(s): # Save a copy of this file to the backup directory
THEDATE=`php -r 'print date('Ymd');'`
THETIME=`php -r 'print date('his');'`
mkdir -p "$TM_BACKUP_DIR/$THEDATE"
perl -e 'while (<STDIN>) { print $_; }' > "$TM_BACKUP_DIR/$THEDATE/$TM_FILENAME.$THEDATE.$THETIME.backup"
Std In: Entire Document
Std Out: Discard
Activation: Key Equivalent Cmd-S
Now each time you save with Cmd-S, TM will also save a copy of the file into your $TM_BACKUP_DIR. It will also organize them into folders for each day at save time.
You may want to run some sort of cron job to clean out the older files in the directory.
Scratch another item off my TextMate wishlist.
- Command: grep -n '^:space:?*\(public\|private\|protected\)\?\(:space:?\+static\|:space:?\+abstract\)\?:space:?\+function'
- Command: grep -n '^:space:?*\(public\|private\|protected\)\?\(:space:?\+static\|
:space:?\+abstract\)\?:space:?\+function'
- Pattern: ^(\d+):\s(public|private|protected)?(\s+static|\s+abstract)?\s+function\s+([_A-Za-z][_A-Za-z0-9]*)\s*[(](.*)[)]
- Pattern: ^(\d+):\s(public|private|protected)?(\s+static|\s+abstract)?
\s+function\s+([_A-Za-z][_A-Za-z0-9]*)\s*[(](.*)[)]
This works great for Transmit also, just replace "Interarchy" with "Transmit". -- natebeaty
Look up current word (doesn't need to be selected) in dictionary (10.4+ only) -- Provided by pbx
There's a more simpleminded way to do this, namely the dict:// pseudo-protocol, but it requires Dictionary to be already running and it fails when an exact match is found. This solution overcomes both those problems.
Look up current word (doesn't need to be selected) in dictionary (10.4+ only) -- Provided by pbx
There's a more simpleminded way to do this, namely the dict:// pseudo-protocol, but it requires Dictionary to be already running and it fails when an exact match is not found. This solution overcomes both those problems.
There's a more simpleminded way to do this, namely the dict:// pseudo-protocol, but it requires Dictionary to be already running and it fails when an exact match is found. This solution overcomes both those problems.
Command:
Look up current word (doesn't need to be selected) in dictionary -- 10.4+ only
Look up current word (doesn't need to be selected) in dictionary (10.4+ only) -- Provided by pbx
-- pbx
Command:
HTML
Get Image Size
This gets an image's width/height using a command and puts it into a tooltip. (make sure you select the image filename relative to the current document)
Look up current word (doesn't need to be selected) in dictionary -- 10.4+ only
Input: none; Output: Do Nothing
# Adapted from: http://daringfireball.net/2005/05/dictionary_bbedit osascript -e "tell application \"Dictionary\" to activate tell application \"System Events\" tell process \"Dictionary\" tell text field 1 of group 1 of tool bar 1 of window \"Dictionary and Thesaurus\" keystroke \"$TM_CURRENT_WORD\" keystroke return end tell end tell end tell"
=] -- pbx
HTML
Get Image Size
This gets an image's width/height using a command and puts it into a tooltip. (make sure you select the image filename relative to the current document)
[=
I’ve created a couple of scripts that give the effect of code completion.
I've created a couple of scripts that give the effect of code completion.
Opens a Terminal window in the current file’s directory.
Opens a Terminal window in the current file's directory.
I’ve created a document that may help Japanese keymap users to type in backslash character in TextMate documents.
I've created a document that may help Japanese keymap users to type in backslash character in TextMate documents.
Add prefix and suffix to lines - Sune Simonsen
Sum all numbers following a '$', useful for adding costs - Jim Bagrow
This just goes through the selected text and adds up all the numbers that follow a '$', simple way to add up costs. Wrote it in python, I'm sure it can be done MUCH more compactly in something more appropriate. Feel free to improve!
- Command: sed 's/^/${1:prefix}/' | sed 's/$/${2:suffix}/'
- Command: #!/usr/bin/python
import os import string import re # get selected text from shell: text = os.getenv('TM_SELECTED_TEXT') # find all numbers following a $ in selection: p = re.compile('\-+?([0-9]*\.[0-9]+|[0-9]+)') result = p.findall(text) sum_num = sum([float(i) for i in result]) result = ["$"+i for i in result] output_str = string.join(result, " + ") print "Sum of costs in selected text:" print output_str, "= $"+str(sum_num)
- Std out: Insert as snippet
- Std out: Insert after selected text
Clickable Function List - Eric Hsu
A command to give you a clickable function list in a seperate window. Replace "^sub " with whatever pattern is applicable for your language.
Add prefix and suffix to lines - Sune Simonsen
- Save: Nothing - Command: sed 's/^/${1:prefix}/' | sed 's/$/${2:suffix}/' - Std In: Selected text - Std out: Insert as snippet
=]
Clickable Function List - Eric Hsu
A command to give you a clickable function list in a seperate window. Replace "^sub " with whatever pattern is applicable for your language.
[=
I’ve created a couple of scripts that give the effect of code completion.
I’ve created a couple of scripts that give the effect of code completion.
Opens a Terminal window in the current file’s directory.
Opens a Terminal window in the current file’s directory.
I’ve created a document that may help Japanese keymap users to type in backslash character in TextMate documents.
I’ve created a document that may help Japanese keymap users to type in backslash character in TextMate documents.
Requires flashcommand: http://weblogs.macromedia.com/mesh/archives/2004/02/flashcommand_fl_1.cfm
Requires flashcommand: http://weblogs.macromedia.com/mesh/archives/2004/02/flashcommand_fl_1.cfm
Tricks for Japanese users
Input backslash character - OGURA Toshiyuki a.k.a. OGURADIO
I’ve created a document that may help Japanese keymap users to type in backslash character in TextMate documents. Description at http://www.oguradio.com/blog/archives/2005/09/textmate.html
Drop Colorcodes From Pref's Colorwheel
TextMate doesn't have a color palette under one of the menus, but you can use the one from the Preferences.. Open the Preferences, go to "Fonts & Colors", click any of the color rectangles *twice* - once to bring up the color palette and again to deselect the rectangle - and close the Preferences window again. Now you can use the color palette to choose a color and drag it into the editing window as a Web #RGB code! -- M Spreij
An update of the apparently deprecated method described here.
An update of the apparently deprecated method described here. Requires flashcommand: http://weblogs.macromedia.com/mesh/archives/2004/02/flashcommand_fl_1.cfm
- A simpler way:
sed 's=^=//='
- A simpler way:
- A simpler way:
sed 's=^[ \t]*//=='
- A simpler way:
Make a command that takes the selected text and execute
[= sed 's/^/${1:prefix}/' | sed 's/$/${2:suffix}/'
[=
- Save: Nothing - Command: sed 's/^/${1:prefix}/' | sed 's/$/${2:suffix}/' - Std In: Selected text - Std out: Insert as snippet
then select inserts as a snippet.
Prefix and suffix a text:
Add prefix and suffix to lines - Sune Simonsen
[=
=]
Prefix and suffix a text: Make a command that takes the selected text and execute sed 's/^/${1:prefix}/' | sed 's/$/${2:suffix}/' then select inserts as a snippet.
Applescript to trigger Interarchy Auto Upload with command - Provided by Alan Odgaard
This neat line of code sends the active TextMate file to Interarchy. If the file is on an auto-upload path, you can publish the file with a simple keystroke.
osascript -e 'tell app "Interarchy" to open POSIX file "'"$TM_FILEPATH"'"'
±¾ÈË´ÓÊ»¥ÁªÍø[http://www.googletosh.com/ ÍøÕ¾½¨Éè][http://www.googleandbaidu.com/ ÍøÕ¾½¨Éè] [http://www.googletosh.com/ ÍøÕ¾ÍÆ¹ã][http://www.googleandbaidu.com/ ÍøÕ¾½¨Éè],ÏÖÊÖÉÏÓÐÒ»ÅúÍøÕ¾£¬ È磺[http://www.postdream.org/ ¹«Ë¾×¢ á/][http://www.postdream.org/ ÉϺ£×¢ ṫ˾] [http://www.dreamathk.com/ ×¢ áÏã¸Û¹«][http://www.dreamathk.com/ Ïã¸Û¹«Ë¾] [http://www.shrentcar.com/ ×â³µ][http://www.shrentcar.com/ ÉϺ£×â³µ][http://www.shrentcar.com/ Æû³µ×âÁÞ] [http://www.revivedata.com/ Êý¾Ý»Ö¸´][http://www.revivedata.com/ Êý¾ÝÐÞ¸´] [http://www.translatebbs.com/ ·Òë]ºÍ[http://www.translatebbs.com/ Ó¢Óï·Òë] [http://www.shticket.com/ »úƱ][http://www.shticket.com/ Ô¤¶©»úƱ] »¹Óнö âÊԵģº[http://www.hklactwo.com/ ÁùºÏ Ê]¡¢[http://www.hklacone.com/ ÁùºÏ Ê/×ã Ê/Ïã¸ÛÁùºÏ Ê] [http://www.hklacone.com/ Ïã¸ÛÁùºÏ Ê][http://www.hklacone.com/ ×ã Ê]£¬»¹Óкó¼ÓµÄ£º[http://www.googletosh.org/Company.htm ×¢ áÏã¸Û¹«Ë¾] [http://www.88775.com/ ÁùºÏ Ê]£¬µÈµÈ£¬Èç¹ûÄã´ÓÊÂÏà¹ØÐÐÒµ£¬ [http://www.dreamatsh.com/ ×¢ ṫ˾][http://www.dreamatsh.com/ ¹«Ë¾×¢ á][http://www.hklacone.com/lac2/ ÁùºÏ Ê] [http://www.curevitiligo.com/English/ vitiligo][http://www.yousanya.com ÈýÑÇÂÃÓÎ]|[http://www.wchao.net/jp/ »úƱ] [http://www.regsh.com/ ¹«Ë¾×¢ á/ÉϺ£×¢ ṫ˾][http://www.dela88.com/ ·À¾ µç/·À¾ µç úÆ·][http://haungsanok.com/ ·À¾ µç/·À¾ µçÒÎ×Ó] [http://www.tripto.com/ ÈýÑÇ][http://www.tripto.com/ ÈýÑÇÂÃÓÎ][http://www.hklactwo.com/lac2/ ÁùºÏ Ê] [http://www.goodsanya.com/ ÁùºÏ Ê][http://www.dreamhk.org/ ×¢ áÏã¸Û¹«Ë¾] [http://duweb.w2.ftpcn.cn/ Êý¾ÝÐÞ¸´][http://duweb.w2.ftpcn.cn/ Êý¾Ý»Ö¸´] [http://sticket.w2.ftpcn.cn/ »úƱ] »òÓÐÒÔÉϵÄͬÀàµÄÍøÕ¾£¬¿ÉÒÔ×ö»¥»ÝÁ´½Ó£¬email:sales@wchao.net
Table of Contents:
Please add all your clever howtos, if you discovered what it takes.
How to use current date and full user name in templates: http://one.textdrive.com/pipermail/textmate/2004-October/000472.html
How to launch TextMate from the shell reading from stdin: http://one.textdrive.com/pipermail/textmate/2004-October/000323.html
How to embed the word/selection in an arbitrary start/stop tag: http://one.textdrive.com/pipermail/textmate/2004-October/000362.html
How to obtain beta versions: http://one.textdrive.com/pipermail/textmate/2004-October/000491.html
Useful Commands
- Double Slash Comments
sed 's/^.*/\/\/&/'
- Double Slash UnComment
sed 's/^[ \t]*\/\/\(.*\)/\1/'
Clickable Function List - Eric Hsu
A command to give you a clickable function list in a seperate window. Replace "^sub " with whatever pattern is applicable for your language.
- before: Do Nothing - Command: grep -n "^sub " - Std In: Entire document - Std out: Show in separate win - Pattern: ^(\d+):(.*)$ [this parses out the grep output so we can identify the line part] - Format: $2 - Line:1
Here's a version of that more useful with PHP 5 (compatible w/ PHP 4 functions, too)... Sorry the pattern's so wide; anyone with a bit more regexp experience think they can cut that down a bit? I couldn't get \s
to work with grep
. =/
- Before: Do Nothing - Command: grep -n '^[[:space:]]*\(public\|private\|protected\)\?\([[:space:]]\+static\|[[:space:]]\+abstract\)\?[[:space:]]\+function' - Std In: Entire Document - Std out: Show in separate win - Pattern: ^(\d+):\s(public|private|protected)?(\s+static|\s+abstract)?\s+function\s+([_A-Za-z][_A-Za-z0-9]*)\s*[(](.*)[)] - Format: $2$3 $4\( $5 \) - Line: 1
PHP Tricks
PHP code completion - Ian White
I’ve created a couple of scripts that give the effect of code completion. Description and download at http://ian.ardes.com/phpcc
PHP documentation command for selected word:
Before running command: do nothing Command(s): open http://nl.php.net/$TM_CURRENT_WORD Standard in/output: None/Discard
PHP Documentation - M Spreij
I created a PHP shell script that will get just the first few lines (function name, php versions and syntax format) from http://php.net, it was a snap to tie it to a tooltip command as well:
Before running command: do nothing Command(s): ~/bin/pdoc $TM_CURRENT_WORD Standard input: Selected Text Standard output: Show as tooltip
Example image
And this opens the doc page in the browser:
Before running command: do nothing Command(s): open http://php.net/$TM_CURRENT_WORD Standard in/output: None/Discard
Applescript
Open Terminal Here - Sam Stephenson
Opens a Terminal window in the current file’s directory.
Before running command: Do nothing
Command(s): osascript -e "tell application \"Terminal\"
activate
set dir to \"$(echo $TM_DIRECTORY | sed 's,[\\"],\\&,g')\"
do script \"cd \" & quoted form of dir
end tell"
Standard input: None
Standard output: Discard
Applescript to open the current file in an arbitrary application - Jeroen van der Ham
Perhaps this is peanuts for people who know Applescript, but I searched for a couple of hours before I could find how to use Unix-style filepaths in an applescript:
osascript -e "tell application \"Preview\" activate open POSIX file \"${TM_FILEPATH\" end tell"
This command be useful for example when editing .tex
files, running latex
over it and previewing the resulting PDF in one go. In which case you need to replace the extension as well, so then you should use the line below.
open POSIX file \"${TM_FILEPATH%/.tex/.pdf}\"
This didn't work for me. I used:
open POSIX file \"${TM_FILEPATH%.tex}.pdf\"
instead.
HTML
Get Image Size
This gets an image's width/height using a command and puts it into a tooltip. (make sure you select the image filename relative to the current document)
- Before command: do nothing - Command: sips -g pixelWidth -g pixelHeight $TM_SELECTED_TEXT - Standard Input: Selected Text - Standard Output: Show as tooltip
-- Ben Parzybok
Actionscript
Macromedia AS Dictionary integration
http://www.partlyhuman.com/wordpress/archives/2005/02/07/textmate-flash-help-integration/
Building a Project in Flash
http://www.partlyhuman.com/wordpress/archives/2005/02/07/building-flash-in-textmate/ An update of the apparently deprecated method described here.
Table of Contents:
Please add all your clever howtos, if you discovered what it takes.
How to use current date and full user name in templates: http://one.textdrive.com/pipermail/textmate/2004-October/000472.html
How to launch TextMate from the shell reading from stdin: http://one.textdrive.com/pipermail/textmate/2004-October/000323.html
How to embed the word/selection in an arbitrary start/stop tag: http://one.textdrive.com/pipermail/textmate/2004-October/000362.html
How to obtain beta versions: http://one.textdrive.com/pipermail/textmate/2004-October/000491.html
Useful Commands
- Double Slash Comments
sed 's/^.*/\/\/&/'
- Double Slash UnComment
sed 's/^[ \t]*\/\/\(.*\)/\1/'
Clickable Function List - Eric Hsu
A command to give you a clickable function list in a seperate window. Replace "^sub " with whatever pattern is applicable for your language.
- before: Do Nothing - Command: grep -n "^sub " - Std In: Entire document - Std out: Show in separate win - Pattern: ^(\d+):(.*)$ [this parses out the grep output so we can identify the line part] - Format: $2 - Line:1
Here's a version of that more useful with PHP 5 (compatible w/ PHP 4 functions, too)... Sorry the pattern's so wide; anyone with a bit more regexp experience think they can cut that down a bit? I couldn't get \s
to work with grep
. =/
- Before: Do Nothing - Command: grep -n '^[[:space:]]*\(public\|private\|protected\)\?\([[:space:]]\+static\|[[:space:]]\+abstract\)\?[[:space:]]\+function' - Std In: Entire Document - Std out: Show in separate win - Pattern: ^(\d+):\s(public|private|protected)?(\s+static|\s+abstract)?\s+function\s+([_A-Za-z][_A-Za-z0-9]*)\s*[(](.*)[)] - Format: $2$3 $4\( $5 \) - Line: 1
PHP Tricks
PHP code completion - Ian White
I’ve created a couple of scripts that give the effect of code completion. Description and download at http://ian.ardes.com/phpcc
PHP documentation command for selected word:
Before running command: do nothing Command(s): open http://nl.php.net/$TM_CURRENT_WORD Standard in/output: None/Discard
PHP Documentation - M Spreij
I created a PHP shell script that will get just the first few lines (function name, php versions and syntax format) from http://php.net, it was a snap to tie it to a tooltip command as well:
Before running command: do nothing Command(s): ~/bin/pdoc $TM_CURRENT_WORD Standard input: Selected Text Standard output: Show as tooltip
Example image
And this opens the doc page in the browser:
Before running command: do nothing Command(s): open http://php.net/$TM_CURRENT_WORD Standard in/output: None/Discard
Applescript
Open Terminal Here - Sam Stephenson
Opens a Terminal window in the current file’s directory.
Before running command: Do nothing
Command(s): osascript -e "tell application \"Terminal\"
activate
set dir to \"$(echo $TM_DIRECTORY | sed 's,[\\"],\\&,g')\"
do script \"cd \" & quoted form of dir
end tell"
Standard input: None
Standard output: Discard
Applescript to open the current file in an arbitrary application - Jeroen van der Ham
Perhaps this is peanuts for people who know Applescript, but I searched for a couple of hours before I could find how to use Unix-style filepaths in an applescript:
osascript -e "tell application \"Preview\" activate open POSIX file \"${TM_FILEPATH\" end tell"
This command be useful for example when editing .tex
files, running latex
over it and previewing the resulting PDF in one go. In which case you need to replace the extension as well, so then you should use the line below.
open POSIX file \"${TM_FILEPATH%/.tex/.pdf}\"
This didn't work for me. I used:
open POSIX file \"${TM_FILEPATH%.tex}.pdf\"
instead.
HTML
Get Image Size
This gets an image's width/height using a command and puts it into a tooltip. (make sure you select the image filename relative to the current document)
- Before command: do nothing - Command: sips -g pixelWidth -g pixelHeight $TM_SELECTED_TEXT - Standard Input: Selected Text - Standard Output: Show as tooltip
-- Ben Parzybok
Actionscript
Macromedia AS Dictionary integration
http://www.partlyhuman.com/wordpress/archives/2005/02/07/textmate-flash-help-integration/
Building a Project in Flash
http://www.partlyhuman.com/wordpress/archives/2005/02/07/building-flash-in-textmate/ An update of the apparently deprecated method described here.
±¾ÈË´ÓÊ»¥ÁªÍø[http://www.googletosh.com/ ÍøÕ¾½¨Éè][http://www.googleandbaidu.com/ ÍøÕ¾½¨Éè] [http://www.googletosh.com/ ÍøÕ¾ÍÆ¹ã][http://www.googleandbaidu.com/ ÍøÕ¾½¨Éè],ÏÖÊÖÉÏÓÐÒ»ÅúÍøÕ¾£¬ È磺[http://www.postdream.org/ ¹«Ë¾×¢ á/][http://www.postdream.org/ ÉϺ£×¢ ṫ˾] [http://www.dreamathk.com/ ×¢ áÏã¸Û¹«][http://www.dreamathk.com/ Ïã¸Û¹«Ë¾] [http://www.shrentcar.com/ ×â³µ][http://www.shrentcar.com/ ÉϺ£×â³µ][http://www.shrentcar.com/ Æû³µ×âÁÞ] [http://www.revivedata.com/ Êý¾Ý»Ö¸´][http://www.revivedata.com/ Êý¾ÝÐÞ¸´] [http://www.translatebbs.com/ ·Òë]ºÍ[http://www.translatebbs.com/ Ó¢Óï·Òë] [http://www.shticket.com/ »úƱ][http://www.shticket.com/ Ô¤¶©»úƱ] »¹Óнö âÊԵģº[http://www.hklactwo.com/ ÁùºÏ Ê]¡¢[http://www.hklacone.com/ ÁùºÏ Ê/×ã Ê/Ïã¸ÛÁùºÏ Ê] [http://www.hklacone.com/ Ïã¸ÛÁùºÏ Ê][http://www.hklacone.com/ ×ã Ê]£¬»¹Óкó¼ÓµÄ£º[http://www.googletosh.org/Company.htm ×¢ áÏã¸Û¹«Ë¾] [http://www.88775.com/ ÁùºÏ Ê]£¬µÈµÈ£¬Èç¹ûÄã´ÓÊÂÏà¹ØÐÐÒµ£¬ [http://www.dreamatsh.com/ ×¢ ṫ˾][http://www.dreamatsh.com/ ¹«Ë¾×¢ á][http://www.hklacone.com/lac2/ ÁùºÏ Ê] [http://www.curevitiligo.com/English/ vitiligo][http://www.yousanya.com ÈýÑÇÂÃÓÎ]|[http://www.wchao.net/jp/ »úƱ] [http://www.regsh.com/ ¹«Ë¾×¢ á/ÉϺ£×¢ ṫ˾][http://www.dela88.com/ ·À¾ µç/·À¾ µç úÆ·][http://haungsanok.com/ ·À¾ µç/·À¾ µçÒÎ×Ó] [http://www.tripto.com/ ÈýÑÇ][http://www.tripto.com/ ÈýÑÇÂÃÓÎ][http://www.hklactwo.com/lac2/ ÁùºÏ Ê] [http://www.goodsanya.com/ ÁùºÏ Ê][http://www.dreamhk.org/ ×¢ áÏã¸Û¹«Ë¾] [http://duweb.w2.ftpcn.cn/ Êý¾ÝÐÞ¸´][http://duweb.w2.ftpcn.cn/ Êý¾Ý»Ö¸´] [http://sticket.w2.ftpcn.cn/ »úƱ] »òÓÐÒÔÉϵÄͬÀàµÄÍøÕ¾£¬¿ÉÒÔ×ö»¥»ÝÁ´½Ó£¬email:sales@wchao.net
Here's a pattern I've come up with for PHP 5 function lists:
Here's a version of that more useful with PHP 5 (compatible w/ PHP 4 functions, too)... Sorry the pattern's so wide; anyone with a bit more regexp experience think they can cut that down a bit? I couldn't get \s
to work with grep
. =/
- Command: grep -n '^\W*\(public\|private\|protected\)\?\(\W\+static\|\W\+abstract\)\?\W\+function'
- Before: Do Nothing - Command: grep -n '^:space:?*\(public\|private\|protected\)\?\(:space:?\+static\|:space:?\+abstract\)\?:space:?\+function' - Std In: Entire Document - Std out: Show in separate win - Pattern: ^(\d+):\s(public|private|protected)?(\s+static|\s+abstract)?\s+function\s+([_A-Za-z][_A-Za-z0-9]*)\s*[(](.*)[)] - Format: $2$3 $4\( $5 \) - Line: 1
Here's a pattern I've come up with for PHP 5 function lists:
- Command: grep -n '^\W*\(public\|private\|protected\)\?\(\W\+static\|\W\+abstract\)\?\W\+function'
Actionscript
Macromedia AS Dictionary integration
http://www.partlyhuman.com/wordpress/archives/2005/02/07/textmate-flash-help-integration/
Building a Project in Flash
http://www.partlyhuman.com/wordpress/archives/2005/02/07/building-flash-in-textmate/ An update of the apparently deprecated method described here.
instead.
instead.
HTML
Get Image Size
This gets an image's width/height using a command and puts it into a tooltip. (make sure you select the image filename relative to the current document)
- Before command: do nothing - Command: sips -g pixelWidth -g pixelHeight $TM_SELECTED_TEXT - Standard Input: Selected Text - Standard Output: Show as tooltip
-- Ben Parzybok
PHP code completion - Ian White
PHP code completion - Ian White
PHP documentation command for selected word:
PHP documentation command for selected word:
This didn't work for me. I used:
open POSIX file \"${TM_FILEPATH%.tex}.pdf\"
instead.
[=
=]
Clickable Function List - Eric Hsu
A command to give you a clickable function list in a seperate window. Replace "^sub " with whatever pattern is applicable for your language.
- before: Do Nothing - Command: grep -n "^sub " - Std In: Entire document - Std out: Show in separate win - Pattern: ^(\d+):(.*)$
[this parses out the grep output so we can identify the line part]
- Format: $2 - Line:1
Useful Commands
* Double Slash Comments *sed 's/^.*/\/\/&/'
* Double Slash UnComment *sed 's/^[ \t]*\/\/\(.*\)/\1/'
PHP Tricks
PHP code completion - Ian White
Useful Commands
- Double Slash Comments
sed 's/^.*/\/\/&/'
- Double Slash UnComment
sed 's/^[ \t]*\/\/\(.*\)/\1/'
PHP Tricks
PHP code completion - Ian White
PHP Documentation - M Spreij
PHP Documentation - M Spreij
Applescript
Open Terminal Here - Sam Stephenson
Applescript
Open Terminal Here - Sam Stephenson
Applescript to open the current file in an arbitrary application - Jeroen van der Ham
Applescript to open the current file in an arbitrary application - Jeroen van der Ham
I created a PHP shell script that will get just the first few lines (function name, php versions and syntax format) from http://php.net, it was a snap to tie it to a tooltip command as well:
I created a PHP shell script that will get just the first few lines (function name, php versions and syntax format) from http://php.net, it was a snap to tie it to a tooltip command as well:
Example image
And this opens the doc page in the browser:
Command(s): open http://nl.php.net/$TM_CURRENT_WORD
Command(s): open http://php.net/$TM_CURRENT_WORD
Example image
I created a http://dev.expocom.nl/functions.php?id=64? that will get just the first few lines (function name, php versions and syntax format) from http://PHP.net, it was a snap to tie it to a tooltip command as well:
I created a PHP shell script that will get just the first few lines (function name, php versions and syntax format) from http://php.net, it was a snap to tie it to a tooltip command as well:
PHP code completion - M Spreij
PHP Documentation - M Spreij
PHP code completion - M Spreij
\
\
[=\
[=
I created a http://dev.expocom.nl/functions.php?id=64? that will get just the first few lines (function name, php versions and syntax format) from http://PHP.net, it was a snap to tie it to a tooltip command as well:
Before running command: do nothing Command(s): ~/bin/pdoc $TM_CURRENT_WORD Standard input: Selected Text Standard output: Show as tooltip Before running command: do nothing Command(s): open http://nl.php.net/$TM_CURRENT_WORD Standard in/output: None/Discard
I created a http://dev.expocom.nl/functions.php?id=64? that will get just the first few lines (function name, php versions and syntax format) from http://PHP.net, it was a snap to tie it to a tooltip command as well:
Before running command: do nothing Command(s): ~/bin/pdoc $TM_CURRENT_WORD Standard input: Selected Text Standard output: Show as tooltip
[=\
[=
* Double Slash UnComment
* Double Slash UnComment
[=
[=\
[=
[=\
How to use current date and full user name in templates: http://one.textdrive.com/pipermail/textmate/2004-October/000472.html
How to launch TextMate from the shell reading from stdin: http://one.textdrive.com/pipermail/textmate/2004-October/000323.html
How to embed the word/selection in an arbitrary start/stop tag: http://one.textdrive.com/pipermail/textmate/2004-October/000362.html
How to use current date and full user name in templates: http://one.textdrive.com/pipermail/textmate/2004-October/000472.html
How to launch TextMate from the shell reading from stdin: http://one.textdrive.com/pipermail/textmate/2004-October/000323.html
How to embed the word/selection in an arbitrary start/stop tag: http://one.textdrive.com/pipermail/textmate/2004-October/000362.html
[=
[=
=]
=]
[=
[=
=]
[=
=] [=
=]
=]
[=
[=
=] =======
- [=
=] [=
=]
=]
[=
[=
=]
=]
\
\
[=
[=
=]
=]
[=
[=
=]
=]
Open Terminal Here - Sam Stephenson
Applescript
Open Terminal Here - Sam Stephenson
Before running command: Do nothing
Command(s): osascript -e "tell application \"Terminal\"
activate
set dir to \"$(echo $TM_DIRECTORY | sed 's,[\\"],\\&,g')\"
do script \"cd \" & quoted form of dir
end tell"
Standard input: None
Standard output: Discard
Applescript to open the current file in an arbitrary application - Jeroen van der Ham
Perhaps this is peanuts for people who know Applescript, but I searched for a couple of hours before I could find how to use Unix-style filepaths in an applescript:
Before running command: Do nothing Command(s):
osascript -e "tell application \"Terminal\" activate set dir to \"$(echo $TM_DIRECTORY | sed 's,[\\"],\\&,g')\" do script \"cd \" & quoted form of dir end tell"
Standard input: None Standard output: Discard
osascript -e "tell application \"Preview\"
activate open POSIX file \"${TM_FILEPATH\"
end tell"
Applescript
Applescript to open the current file in an arbitrary application - Jeroen van der Ham
Perhaps this is peanuts for people who know Applescript, but I searched for a couple of hours before I could find how to use Unix-style filepaths in an applescript:
This command be useful for example when editing .tex
files, running latex
over it and previewing the resulting PDF in one go. In which case you need to replace the extension as well, so then you should use the line below.
osascript -e "tell application \"Preview\"
activate open POSIX file \"${TM_FILEPATH\"
end tell"
open POSIX file \"${TM_FILEPATH%/.tex/.pdf}\"
This command be useful for example when editing .tex
files, running latex
over it and previewing the resulting PDF in one go. In which case you need to replace the extension as well, so then you should use the line below.
open POSIX file \"${TM_FILEPATH%/.tex/.pdf}\"
-->[=
[=
=======
- [=
[=
>>>>>>>
Example image
Open Terminal Here
Opens a Terminal window in the current file’s directory.
=======
- Before running command: do nothing Command(s): open http://nl.php.net/$TM_CURRENT_WORD Standard in/output: None/Discard
I created a http://dev.expocom.nl/functions.php?id=64? that will get just the first few lines (function name, php versions and syntax format) from http://PHP.net, it was a snap to tie it to a tooltip command as well:
Before running command: do nothing Command(s): ~/bin/pdoc $TM_CURRENT_WORD Standard input: Selected Text Standard output: Show as tooltip =]
Example image
Open Terminal Here - Sam Stephenson
Opens a Terminal window in the current file’s directory.
[=
Sam Stephenson
Applescript
Applescript to open the current file in an arbitrary application - Jeroen van der Ham
Perhaps this is peanuts for people who know Applescript, but I searched for a couple of hours before I could find how to use Unix-style filepaths in an applescript:
osascript -e "tell application \"Preview\" activate open POSIX file \"${TM_FILEPATH\" end tell"
This command be useful for example when editing .tex
files, running latex
over it and previewing the resulting PDF in one go. In which case you need to replace the extension as well, so then you should use the line below.
open POSIX file \"${TM_FILEPATH%/.tex/.pdf}\"
- [=
-->[=
Example image
Open Terminal Here
Opens a Terminal window in the current file’s directory.
=======
- Before running command: do nothing Command(s): open http://nl.php.net/$TM_CURRENT_WORD Standard in/output: None/Discard
I created a http://dev.expocom.nl/functions.php?id=64? that will get just the first few lines (function name, php versions and syntax format) from http://PHP.net, it was a snap to tie it to a tooltip command as well:
Before running command: Do nothing Command(s):
osascript -e "tell application \"Terminal\" activate set dir to \"$(echo $TM_DIRECTORY | sed 's,[\\"],\\&,g')\" do script \"cd \" & quoted form of dir end tell"
Standard input: None Standard output: Discard
Before running command: do nothing Command(s): ~/bin/pdoc $TM_CURRENT_WORD Standard input: Selected Text Standard output: Show as tooltip
Sam Stephenson
>>>>>>>
Example image
Open Terminal Here
Opens a Terminal window in the current file’s directory.
Before running command: Do nothing Command(s): osascript -e "tell application \"Terminal\" activate set dir to \"$(echo $TM_DIRECTORY | sed 's,[\\"],\\&,g')\" do script \"cd \" & quoted form of dir end tell" Standard input: None Standard output: Discard
Sam Stephenson
Before running command: do nothing
Command(s): open http://nl.php.net/$TM_CURRENT_WORD
Standard in/output: None/Discard
I created a PHP shell script (update (doh): link) that will get just the first few lines (function name, php versions and syntax format) from http://PHP.net, it was a snap to tie it to a tooltip command as well:
Before running command: do nothing
Command(s): ~/bin/pdoc $TM_CURRENT_WORD
Standard input: Selected Text
Standard output: Show as tooltip
- Before running command: do nothing Command(s): open http://nl.php.net/$TM_CURRENT_WORD Standard in/output: None/Discard
I created a http://dev.expocom.nl/functions.php?id=64? that will get just the first few lines (function name, php versions and syntax format) from http://PHP.net, it was a snap to tie it to a tooltip command as well:
Before running command: do nothing Command(s): ~/bin/pdoc $TM_CURRENT_WORD Standard input: Selected Text Standard output: Show as tooltip
Open Terminal Here
Opens a Terminal window in the current file’s directory.
Before running command: Do nothing Command(s): osascript -e "tell application \"Terminal\" activate set dir to \"$(echo $TM_DIRECTORY | sed 's,[\\"],\\&,g')\" do script \"cd \" & quoted form of dir end tell" Standard input: None Standard output: Discard
Sam Stephenson
@@Before running command: do nothing Command(s): open http://nl.php.net/$TM_CURRENT_WORD Standard in/output: None/Discard@@
Before running command: do nothing
Command(s): open http://nl.php.net/$TM_CURRENT_WORD
Standard in/output: None/Discard
@@Before running command: do nothing Command(s): ~/bin/pdoc $TM_CURRENT_WORD Standard input: Selected Text Standard output: Show as tooltip@@
example img at http://www.mechintosh.com/images/misc/tm.png
Before running command: do nothing
Command(s): ~/bin/pdoc $TM_CURRENT_WORD
Standard input: Selected Text
Standard output: Show as tooltip
Example image
Please add all your clever howtos, if you discovered what it takes.
How to use current date and full user name in templates: http://one.textdrive.com/pipermail/textmate/2004-October/000472.html
How to launch TextMate from the shell reading from stdin: http://one.textdrive.com/pipermail/textmate/2004-October/000323.html
How to embed the word/selection in an arbitrary start/stop tag: http://one.textdrive.com/pipermail/textmate/2004-October/000362.html
How to obtain beta versions: http://one.textdrive.com/pipermail/textmate/2004-October/000491.html
Useful Commands
* Double Slash Comments *sed 's/^.*/\/\/&/'
* Double Slash UnComment *sed 's/^[ \t]*\/\/\(.*\)/\1/'
PHP Tricks
PHP code completion - Ian White
I’ve created a couple of scripts that give the effect of code completion. Description and download at http://ian.ardes.com/phpcc PHP documentation command for selected word:
@@Before running command: do nothing Command(s): open http://nl.php.net/$TM_CURRENT_WORD Standard in/output: None/Discard@@
I created a PHP shell script (update (doh): link) that will get just the first few lines (function name, php versions and syntax format) from http://PHP.net, it was a snap to tie it to a tooltip command as well:
@@Before running command: do nothing Command(s): ~/bin/pdoc $TM_CURRENT_WORD Standard input: Selected Text Standard output: Show as tooltip@@
example img at http://www.mechintosh.com/images/misc/tm.png