Hi all,
I'm looking to extend the definition of a comment in the textmate
syntax highlighting, but I'm not quite sure how to achieve the effect
I'm after.
I frequently comment out snippets of code by sticking `if (false)
{ ... }` around the code. The other variation I use is to convert an
existing condition into a comment: `if (false && previous condition)
{ ... }`. You don't want to over-use this idiom, but it is useful in
its place.
At the moment TextMate treats this just like normal code (which is
exactly what you'd expect). I was wondering if there was a way to
make TextMate see these patterns as comments. It isn't easy as you
really want to pick the right brace to close the comment. There could
be further blocks of code nested inside the 'comment block'.
This isn't a huge priority for me, but I thought I'd raise it and
see if anyone had any obvious solutions.
Be well,
Will :-}
Hello,
How can I get 10.5.6 to use TextMate as the default application to
open text files instead of using TextEdit?
For example, if I do the following, I'd like the new file to open in
TextMate:
grep 'test' *.c > newfile
open newfile
Currently, this opens in TextEdit (ugh).
For files with an extension, I can get the system to use TextMate for
all files with that extension.
But I'd like something that works automatically for files without
extensions (like "newfile" in the example).
Also while it works to use "get info" to set the "open with"
application for an existing file,
when I do "Change All..." to use TextMate, I get the following error:
An error occurred while changing the application that
open "newfile" because not enough information is
available.
I'm using Version 1.5.8 (1498).
Thanks,
Bill Paxton
The class snippet in the Java bundle (from SVN) is not working as
expected for me. It fails guessing the correct class name from the
file name.
The regex for the class name guessing looks like this in the current snippet:
${TM_FILENAME/(.*?)(\..+)?/(?2:$1:untitled)/}
For a file that is not yet saved I get "class untitled ..." as
expected. However, if I have a Java file TestClass.java the snippet
names the class "untitledTestClass.java" - not what it is ment to be.
In an very old version of the bundle the regex in that snippet was:
${TM_FILENAME/(\w+).*|(.*)/(?1:$1)(?2:ClassName)/}
This one works for me (TM). I hope this is a good pointer to get the
snippet working again in the current bundle.
I also asked myself, whether the regex should be "improved" in such a
way, that it only accepts valid Java identifiers as class names and
otherwise informs the user about it. Nor sure whether this is beyond
the scope of the snippet, so I would like to hear some opinions, befor
I start messing with the regex ;-)
A possible improvement could be like this IMHO:
* A file MyClass.txt results in "class MyClass". As long as the
identifier is valid inside the Java file, the snippet should not care
about inapropriate named files.
* Same goes for file/class names that are against naming conventions
but compile fine anyway: class myclass, class Myclass, etc.
* The regex _should_ complain when file/class name doesn't start with
a Unicode letter, underscore, or currency symbol (dollar, euro, yen
sign). e.g. 1MyClass is not a valid class name (error at compile
time). The snippet could give the user a hint early in the process by
naming the class "class InvalidClassName" or something
* The alphabet for class names _should_ be restricted to Unicode
letters, digets, underscore and currency symbols
* keywords are not allowed as Identifiers but I'd say that's beyond
the scope of the snippet check that too
Last but not least it would be great if the tab triggers were the same
between packages for common snippets like class: python has class-->,
ruby has cla-->, java has cl-->
> { name = 'meta.test';
> match = '^(ATOM|HETATM).*(GLN)';
> captures = {
> 1 = { name = 'keyword.first-match'; };
> 2 = { name = 'string.second-match'; };
> };
> }
>
> This should color each match differently. Please note that there are
> many different ways to do this and may not be the best way for your
> needs.
>
> Do yourself a favor and look up some regex tutorials on the web. They
> will help immensely.
>
> --oliver
captures = {
1 = { name = 'keyword.first-match'; };
2 = { name = 'string.second-match'; };
};
That was the missing link I was looking for.
Thanks Oliver.
Marc
> his indeed works but I do think I need to be a bit more specific.
> Lets look again at the line:
>
> ATOM 14 CA GLN A 2 -27.648 -9.581 30.325 1.00 10.00
>
> My goal is to have both the 'ATOM' string and the 'GLN' string colored
> differently.
>
> Using ^(ATOM|HETATM)\b I can color the ATOM part.
> Using \bGLN\b I can color the GLN part.
>
> The problem is that I only want the GLN part to be colored if the line
> starts with ATOM. In your reply the complete part starting with ATOM
> up to GLN gets colored.
>
> Marc
Dear all,
Thanks for all comments and tips on my "Conditional regex" question.
Nevertheless I'm still a bit of a novice when it deals with regular
expressions.
Although I can see the logic in many of your tips I'm still unable to
put the
bits and pieced together into a functional expression.
Would anyone of you be so kind to provide me with a more elaborate
answer/example?
Thanks,
Marc
>> I believe this is the correct firstLineMatch for AS3:
>> package\s?([\w\.]*)\s?{
>
> You need to add a ^ assertion to the beginning of that at least. And
> you need to make sure it can't get triggered in D, Doxygen, Groovy,
> Java, JavaScript, Processing, Scala. (The languages I quickly scanned
> to see have a package keyword that could get tripped up)
I did some quick research:
- The Java-based languages use a semi-colon, rather than a brace.
- D uses 'module' to define its packages.
- Before I added the firstLineMatch, my files were coming up as
plain-text. If there's a language this pattern conflicts with,
TextMate doesn't know about it out-of-the-box.
Here's a slightly-modified version that caps the ends of the string.
It also makes the { optional (in case someone puts his braces on the
next line):
^package\s?([\w\.]*)\s?{?$
> I used \bAS3\b because comments are as likely to be found on the
> first line as package declarations. So, for anyone who wanted to,
> adding 'AS3' would help TM identify ActionScript 3 over ActionScript
> files.
>
> I've also taken the liberty of adding 'AS3' into the comment header
> for the same reason.
I'd venture a guess that package ... { is the handily the most common
first line of an AS class; however, why don't we use either method?
(^package\s?([\w\.]*)\s?{?$)|(\bAS3\b)
Note: I get this as a first line if I do new AS3 class from template:
package .var.folders.NQ.NQfuLuLLE+aVJJfvkTLNwU+++TI.-Tmp- {
I imagine I'll have plenty to contribute in the way of bundlie-
goodness. I don't personally use a version control system, and I'm
not wed to any of them. Is there any sort of utility that will enable
me to contribute to any of them, so I could fork somebody on github
and somebody else on bitbucket without having to mess with git and hg?
Thanks,
B
Hi,
I've been using TextMate for almost a year now and like it very much.
I'm trying to stay off my mouse and here is one task I think I should be
able to do without using mouse. From time to time, I copy some code to a
new editor window and run. What is the keyboard shortcut to invoke the
file type dropdown in the bottom of the editor?
Thank you.
Cao