Posted on March 19, 2007
I've been using TextMate since probably the first public version. At least my license dialog shows October 6th 2004, Serial Number #60. And, oh boy, I've been a happy user. I can't declare that this is the best editor out there, and I don't want to start another editor vs war. I've been using Vi(m)/emacs for such a long time that I can't even remember and I'm not going to give up on them just yet. But I can say that TextMate is definitely a unique piece of software that sets a high mark for other editors to follow.
I think the most innovative feature of this editor is the way it represents the document structure with scopes. Everything else is built around this structure: shortcuts, snippets, commands, code highlighting, etc. This very feature makes it so much easier to customize your editor, than anything I've seen so far. (Whatever I've tried I couldn't make mmm-mode package work for me).
Another thing that I'd love to have from any editor is a desktop integration. Don't get me wrong, I'm an avid terminal and CLI proponent, but I've access to the most powerful desktop out there and it would be sad if I can't enjoy it when I'm writing my documents. And TextMate allows me enjoying both of these worlds.
OK, enough of TextMate praises, there are still some areas where this editor needs some love. One of them is the search capability. The regular and incremental searches are fine, I'm talking about the Find in Project search. First of all, it's quite slow and it used to take a lot of your RAM. Second of all, I've found that in about 95% of all cases, I need to search in a particular directory of my project. So I did what everyone else does, I created my own command, which I am about to share with you.
Quick Search
This command uses grep utility to search in your documents. It's bound to ⌃⇧F keystroke and uses a selected text or prompts you for a query text. What makes it quite useful is that, if you have a project opened, you can select a directory in the project drawer and this command will limit the search only to this directory and all subdirectories. Also you can define the environment variable TM_QS_FILTER in your project settings with a value of a regular expression that selects all files and directories that you don't want to search in. For example, I'm using (tmp|log|rails)$ value for my Rails projects.
Enjoy.
Filed under: TextMate |
Posted on March 15, 2007
Probably the most boring task when writing Rails test cases is entering new fixtures. With a little help from TextMate this process can be made more pleasant.
- Open Bundle Editor and create a new command.
- Name it, for example, 'rails: new fixture'
- Use this script as the command body:
Filed under: Rails TextMate |
Posted on August 27, 2006
Wouldn't it be great if I can set breakpoints right from within TextMate? I've been thinking about this myself for sometime.
And now I'd like to introduce a new Ruby Debug Bundle.
Note that in order to use it you must have the latest version (0.4.1 or higher) of ruby-debug installed.
How to use it?
Let's say you want to debug your Rails application.
Start your application with the remote debugging enabled:
$ rdebug -sn ./script/server webrick
Connect to the debugger (in new terminal):
$ rdebug -c
Connected.
In TextMate go to the line where you want to set a breakpoint and press ⇧⌘B and select Set Breakpoint at Current Line.
Open your browser and start using your application until you reach the breakpoint.
That's it.
Currently, these commands are available:
- Set Breakpoint at Current Line
- Delete All Breakpoints.
- Show Breakpoints - show all breakpoints as a tooltip.
- Interrupt - interrupt the last debugged thread or, if there is no one, the main thread.
- Quit - quit application.
Filed under: ruby-debug TextMate |
7 comments
Posted on March 17, 2006
I've been using TextMate for sometime now and all I can say is wow. I'd never think that someday I'll find another text editor that can replace vim for me.
Sure for simple shell scripts I still prefer vim, especially when I work on a remote host via ssh. But when I'm using my Mac I'm more and more apt to type
$ mate file-name
nowdays.
There are couple of things that I like about TextMate. And one major one is that it is very easy to extend with some help of shell programming. You don't have to learn another language in order to do it. You can always use your favorite one, like Ruby.
For example, one of the features that I miss from my vim days was ability of the editor to complete file names for me.
This simple script provides this functionality for me:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#!/usr/bin/env ruby
index = ENV['TM_LINE_INDEX'].to_i
line = ENV['TM_CURRENT_LINE'][0...index]
filename_char = '(?:\\\\[ \'"&,()]|[\w~.-])'
filename_regexp =
/((?:\/)?(?:#{filename_char}+\/)*)(#{filename_char}*)$/
if line =~ filename_regexp
dir, prefix = $1, $2
Dir.chdir File.expand_path(dir) rescue exit
matched = Dir["#{prefix}*"]
if matched.size == 1
print matched.first.sub(/^#{prefix}/, '')
else
args = matched.map{|f| "\"#{f}\""}.join(', ')
result, value = %x{
"#{ENV['TM_SUPPORT_PATH']}/bin/CocoaDialog.app/Contents/MacOS/CocoaDialog\" dropdown \
--title 'Possible file names' \
--text 'Choose correct filename for insertion, or escape to cancel.' \
--button1 Ok --button2 Cancel \
--string-output --no-newline \
--items #{matched.map{|f| "\"#{f}\""}.join(' ')}
}.split(/\n/)
print value.sub(/^#{prefix}/, '').
gsub(/(['"&,() ])/){"\\#$1"} if result == 'Ok'
end
end
|
Now when you create this command in TextMate Bundle Editor, make sure that you use None for Input, and Insert as Text for Output. That's it.
Filed under: TextMate |
0 comments