Hi folks,
I missed a command from BBEdit that let you comment and uncomment
text magically for different languages with the same keystroke
(Text->Un/Comment), so I wrote a version for TextMate. If there is
enough interest, I will release commented source code and make it
into a nice .tmbundle. It currently only supports perl, php, html,
plist and tex. It is trivial to add support for other languages,
which I'll do on request (or you can easily figure out yourself, I
think... if you do, send me an e-mail so I can update mine!).
If the selection's first line is a comment; if so, it uncomments the
rest of the selection.
If not, it comments the whole selection, line by line. It tries to
keep the selection's indentation.
It parses the filetype from the filename ending to figure out what
are comments. If a language has more than one kind of delimiter pair,
it will use the first pair in the list for commenting, and will
search for all listed pairs for uncommenting. Notice this last
feature improves on BBEdit's Text->Un/Comment functionality. The
delimiters are stored in $a in the format "a,b,c"=>[$first, $last],
where each of the file endings .a, .b and .c will use that delimiter
pair. Roll your own!
This version is actually better than BBEdit's, in my opinion, because
1. it can uncomment many different comment formats for silly
languages like PHP that support several; and
2. it places comment delimiters at the original level of indent (and
not the first column like BB does); and
3. we can all customize it.
Textmate is powerful!
best wishes, Eric
--
To install it as a command:
Before: do nothing
Command:
perl -e
'$a={"pl,pm"=>["#",""],"plist,c"=>["/*","*/"],"html,htm"=>["<!--","-->"],"tex,ltx"=>["%",""],"php"=>["#","","/*","*/","<!--","-->","//",""]};while(($k,$v)=each(%$a)){foreach(split(/\s*,\s*/,$k)){$c{"$_"}=$v;}}$_=shift@ARGV;($t)=/\.(.*?)$/;($s,$f,@etc)=@{$c{$t}};$b=0;while(<STDIN>){push@in,$_;($in)=/^([
\t]*)/;$inl=0;foreach$j(1..(length($in))){$ch=substr($in,$j-1,1);if($ch
eq"
"){$inl++;}else{unless($inl%4){$inl+=4;}else{$inl+=$inl%4;}}}unless($i){$ind=$in;$indl=$inl;$i++;}else{if($inl<$indl||$in
eq""){$ind=$in;$indl=$inl;}}}$i=0;foreach(@in){if(chomp){$n="\n";}unless(/\S/){$o.=$_."\n";next;}unless($b){$b=1;foreach$d(@{$c{$t}}){$i=1-$i;$d=quotemeta($d);if($i){if(/^\s*$d/){$y=1;$s=$d;}}elsif($y){$f=$d;last;}}}if($y){s/^(\s*)$s(\
)?/$1/;s/(\ )?$f(\s*)$/$1/;$o.=$_.$n;}else{s/^$ind//;$o.=$ind.$s." $_
".$f.$n;}}print$o;' $TM_FILEPATH
STDIN: Selected
STDOUT: Replace Selected
--
Eric Hsu, Assistant Professor of Mathematics
San Francisco State University
erichsu(a)math.sfsu.edu
http://math.sfsu.edu/hsu
Sometimes you want to execute the SQL contained in the current file via:
Before running command: Do nothing
Command: [your path to mysql if not in bash's path environment
variable]/mysql -u[your username here] -p[your password here] <
"$TM_FILEPATH"
Standard Input: None (because $TM_FILEPATH is specified above; you
could use just selected text too with $TM_SELECTED_TEXT)
Standard Output: Show in separate window
If you have line numbers showing in the gutter you can quickly find any
syntax errors that mysql returns.
Simple. Useful.
After reading peoples comments about ftp programs last week I tried
yummy ftp and I am very close to buying it. I love that I can select a
remote file and hit cmd-B to open it in textmate. Is this the killer
feature people where asking for?
Does anyone else have reviews for this product?
Later,
Eric
PS. I liked it so much I remapped my open in text editor in PathFinder
to cmd-B as well so most of the time I am ready for a quick edit.
I've posted the latest Perl bundle to
http://math.sfsu.edu/hsu/textmate/. Changes do not include
recognition of Coffee Services. :)
They do include:
(12-20-04)
Martin Vetter added [] and () to the Perl folding syntax.
__DATA__ now highlights to the end
q qq qw qx quoting is nicer
Noah Daniels submitted bug fix to color POD starting with ^= and
not just ^=head1
Noah Daniels also submitted bug fix for $#foo being counted as a comment.
Known problems: here-docs not quoted, many autoquotes not
highlighted right, e.g. hashkeys in => notation.
best wishes, Eric
--
Eric Hsu, Assistant Professor of Mathematics
San Francisco State University
erichsu(a)math.sfsu.edu
http://math.sfsu.edu/hsu
Textmate is looking awesome (I just tried it Friday for the first time)
and though I own a copy of BBEdit, I think I may switch. But there are
a couple of things still missing, IMHO.
First, the Perl syntax bundle doesn't handle POD (=begin, =cut, etc.)
yet. I very quickly hacked in support for simply =begin and =cut as
block comments, but it would be ideal if it could do as good a job as
BBEdit's syntax coloring for Perl/POD.
Second, I do miss BBEdit's integration of certain things in its script
menu - 'find in reference' (really just shelling out of perldoc -f) and
'view POD' (just shelling out of perldoc), as well as the ability to
execute in the debugger. It would be nice to be able to, within a
project, execute things like 'perl -d <filename>' and such - or for a
C/C++ program, run it in gdb. I realize this can be done in Textmate
using the Automation->Commands menu, so perhaps what I'm saying is that
a few more built-ins would be nice :)
Finally, for the syntax bundles, the non-uniformity of color schemes
between bundles (I routinely work in projects involving Perl and C
code) could stand to be improved - ideally, a way to graphically change
the colors for the syntax bundles would be nice, too, rather than
editing the bundles. For example, rather than specifying the RGB values
in each syntax plist, have an indirect color code - for example,
"keyword" or "comment" - and then in TextMate have a preference that
allows you to specify colors for all of those, globally.
Anyways, TextMate is looking great. Keep up the good work!
--
"Failure is not an option, it comes bundled with the software" -DefCon
10
Noah M. Daniels
ndaniels(a)mac.com
...Remote file or URL was invalid"
...is the message I got when I try :
"TextMate-->Preferences-->Software Update-->Check Now"
(TextMate v1.0.2 (2004-12-10))
Is it a known issue, or does it come from me?
Best regards,
--
Jo <W:00°04'37" ; N:47°15'36">
1....'....12.....'....24.....'....36.....'....48.....'....60.....'....72
I'm working with a project whose files are on an SMB share. The sort
order of files and folders is not alphabetical, making it crazy
difficult to find files :)
Have I somehow messed up the order? Can I reset it to alpha?
Projects on my local disk are ordered alphabetically as expected.
cheers
drew.
Hi,
Following advice of some people, i'm giving TextMate a try.
There is a feature i don't find in TextMate: hard wrapping. I'm
editing big XML files and i've not figured how to automatically cut
the lines when they reach the right column.
I know about Soft Wrap, but i don't want to use it as the document
will be sent to people who are using different text editors: i don't
want they see a paragraph as a single long long line.
In fact, i'm a Emacs user and i need something like 'auto-fill-mode' :
when the line reaches the right margin, Emacs insert a newline.
To achieve the same thing with TextMate, the only way i've found so
far is to reformat the paragraph or the selection, which is not very
productive.
Is there something to automate this process or should i live with it?
Best regards,
--
Jaco
Please consider at some point changing the soft wrapping algorithm so it
indents to the same level as the first (non-space/tab) character in the
line. Anyone think this would be a *bad* idea (in which case perhaps it
could be a preference)?
-- Russell
P.S. this mailing list is now available from news.gmane.org as news
group gmane.editors.textmate.general.