Hello, I now use BBedit rarely, the times TM just flat out amazes me, I am a happy camper. There are times I still fire up the old BB, but it gets less and less. Maybe I am getting too old to remember all these damn keyboard shortcuts :)
1) Is there an <a href... snippet, I can not find it
2) How can I shift selected text right and left one space at a time?
3) Most other apps allow me to drag and drop a text clipping to the apps icon, and it will open it. In TM, I have to open the clipping, copy, then new file, then paste. Any workarounds on this one? Oddly, I find I used this feature a lot and I am missing it.
4) I am liking soft tabs a lot, as they seem to allow me to align things better, and when files move to other places, they stay lined up regardless of the tab stop setting. I was happily working in 4 spaces per tab stop, and wanted to move to 5, changing it did nothing. I had to convert spaces to tabs, then make the change. I am not entirely sure what I did really. Can someone give me a primer or point me to docs on how this works?
* I am often opening tab separated files, and will need to open tabs to 40 spaces or so, because the launch time to something like Excel is just too aggravating, TM seems to work against me a little for this type of work, suggestions?
5) Given code such as: $foo = 'bar'; $this = 'that'; $something = 'else';
What is a simple way to get to: $foo = 'bar'; $this = 'that'; $something = 'else';
6) I have picked up this TM book and printed it out, it is helping me a lot. There is a section on being able to select some sql, and have it run and show me the output. I am not understanding how to make this work. I usually have a db.inc that will contain my user and pass and db name, so it will be well outside the scope of the file I am in, unless TM can follow that include reference. To be able to run arbitrary sql would be huge for me, is there a better walk through? I am just not getting this one to work. I have not tried to be honest, since I do not understand the setup at all.
7) Any of you care to share your top #1 little tricks, the one thing you use all the time, that just makes you happy every time you invoke it? I mainly work in php, so leaning on things that would be helpful in that area would be nice. Second would be bash, and lately, for some odd reason, I have been spending some time in TCL, but not much, so I am not sure how many tricks in there would benefit me in the long run.
Thanks all... Hey, when is the next version coming out... just kidding :) -- Scott * If you contact me off list replace talklists@ with scott@ *
A few responses ...
- Is there an <a href... snippet, I can not find it
I don't use HTML much but it is *extremely* easy to write your own snippets if you can't find exactly what you're looking for. Give it a shot with the bundle editor.
- I am liking soft tabs a lot, as they seem to allow me to align
things better, and when files move to other places, they stay lined up regardless of the tab stop setting. I was happily working in 4 spaces per tab stop, and wanted to move to 5, changing it did nothing. I had to convert spaces to tabs, then make the change. I am not entirely sure what I did really. Can someone give me a primer or point me to docs on how this works?
I think changing your soft tab amount is only a forward operation. Since it is only inserting spaces for you it probably can't figure what what it inserted as spaces and what you did. Might I recommend using real tabs instead (/ducks!)? :)
- Any of you care to share your top #1 little tricks, the one thing
you use all the time, that just makes you happy every time you invoke it? I mainly work in php, so leaning on things that would be helpful in that area would be nice. Second would be bash, and lately, for some odd reason, I have been spending some time in TCL, but not much, so I am not sure how many tricks in there would benefit me in the long run.
By far my most valuable feature is cmd-t (go to file). Also, the cmd-opt-[ (indent line) works rather well for me. I've also written a couple custom commands that I find very useful (e.g., open up docs based on selected word, statically analyze code, etc).
- I am liking soft tabs a lot, as they seem to allow me to align
things better, and when files move to other places, they stay lined up regardless of the tab stop setting. I was happily working in 4 spaces per tab stop, and wanted to move to 5, changing it did nothing. I had to convert spaces to tabs, then make the change. I am not entirely sure what I did really. Can someone give me a primer or point me to docs on how this works?
I think changing your soft tab amount is only a forward operation. Since it is only inserting spaces for you it probably can't figure what what it inserted as spaces and what you did. Might I recommend using real tabs instead (/ducks!)? :)
I used to use tabs all the time, and was a tabs over spaces guy, but found my files to be a mix of tabs and spaces. I want things to line up where I want them to line up. If I use tabs, they seem to dictate how things will line up.
I will usually tab in the leading tabs I want, and then use spaces to shift things where I want them to be.
Example: $sql = SELECT foo, far, baz FROM balh WHERE foo = '1'
Example using tabs: $sql = SELECT foo, far, baz FROM balh WHERE foo = '1'
As you can see, the S in Select is one off, so I would have to tab them all in more:
Example using more tabs: $sql = SELECT foo, far, baz FROM balh WHERE foo = '1'
This is ok, but falls apart of me in more complex cases. Then, if I ever change the tab stops, things never line up again. If they are all spaces, and also how simple TM makes it for me to move from tabs to spaces and spaces to tabs if I have to give the files to someone else, makes soft tabs seem right for me.
The spaces sort of lock my formatting down, which in my case I like. I know it is an age old debate, and I am not trying to sway anyone :) I just wanted to explain my logic in why I have grown to like this method. In the past it was a lot of tab tab tab space space space operations, I can now use tabs to line it all up, drop in a space or two, and no matter what the tab stops are later, it all lines up nice.
- Any of you care to share your top #1 little tricks, the one thing
you use all the time, that just makes you happy every time you invoke it? I mainly work in php, so leaning on things that would be helpful in that area would be nice. Second would be bash, and lately, for some odd reason, I have been spending some time in TCL, but not much, so I am not sure how many tricks in there would benefit me in the long run.
By far my most valuable feature is cmd-t (go to file). Also, the cmd-opt-[ (indent line) works rather well for me. I've also written a couple custom commands that I find very useful (e.g., open up docs based on selected word, statically analyze code, etc).
I just looked in the apple doc machine thing for tm, indent line is not something I can locate, can you tell me what it is for. I opened a file, invoked it, and it just beeped it me. -- Scott * If you contact me off list replace talklists@ with scott@ *
I just looked in the apple doc machine thing for tm, indent line is not something I can locate, can you tell me what it is for. I opened a file, invoked it, and it just beeped it me.
Really? Worked for me in leopard.
Anyway ... it is the 6th item under the Text menu. It essentially (usually correctly) indents the current line or selection of lines to match your indent pattern.
On Mar 24, 2009, at 2:16 PM, Robert J. Carr wrote:
I just looked in the apple doc machine thing for tm, indent line is not something I can locate, can you tell me what it is for. I opened a file, invoked it, and it just beeped it me.
Really? Worked for me in leopard.
Anyway ... it is the 6th item under the Text menu. It essentially (usually correctly) indents the current line or selection of lines to match your indent pattern
Is this a command or an option you enable or disable? I just paste, and wait for the amazement. Everything I paste drops right into where it should be indented, except when it does not, which can be mildly annoying to get to go where I want if it is one line and I use the tab key, but cmd- brackets work well to get it in line. -- Scott * If you contact me off list replace talklists@ with scott@ *
On 2009-March-24 , at 17:09 , Scott Haneda wrote:
I used to use tabs all the time, and was a tabs over spaces guy, but found my files to be a mix of tabs and spaces. I want things to line up where I want them to line up. If I use tabs, they seem to dictate how things will line up.
I will usually tab in the leading tabs I want, and then use spaces to shift things where I want them to be.
Time for some elastic tabstops in TextMate: http://nickgravgaard.com/elastictabstops/ This approach seems so superior to the rest that Iam surprised so few editors picked it up.
JiHO --- http://jo.irisson.free.fr/
On 24 Mar 2009, at 22:22, JiHO wrote:
[...] I will usually tab in the leading tabs I want, and then use spaces to shift things where I want them to be.
Time for some elastic tabstops in TextMate: http://nickgravgaard.com/elastictabstops/ This approach seems so superior to the rest that Iam surprised so few editors picked it up.
My reply from “back then”:
Indeed it is interesting. I do think there would be too big a compatibility problem with actually saving such files, since all renderings of the file (cat it in terminal, paste it in an email, on the web, etc.) would be wrong — and it’s not easily fixable, e.g. by piping the text through something like expand, which would normally fix presenting a file with the wrong tab size.
Allan Odgaard wrote:
(...) I do think there would be too big a compatibility problem with actually saving such files, since all renderings of the file (cat it in terminal, paste it in an email, on the web, etc.) would be wrong — and it’s not easily fixable, e.g. by piping the text through something like expand, which would normally fix presenting a file with the wrong tab size.
Yeah, that's right. Moreover the proposed "elastic tabs" does describe the method only with this fancy picture, but does not provide exact algorithm or at least block schema how to implement it. So this sounds to me like an empty wish not a standard.
My personal approach to indenting is to use tabs where possible at the beginning of the line, but if there comes first character or chunk of code, I align everything at the right just with spaces, i.e.:
struct { ⇥int counter; /* Some counter */ ⇥struct { ⇥⇥int x; ⇥⇥int y; ⇥} pos; /* Position */ ⇥char *text; /* Inner text */ } CONTEXT;
if(font_name) { ⇥NSString *fontName = [[[NSString alloc] initWithUTF8String: font_name] autorelease]; ⇥NSFont *font = [[NSFontManager sharedFontManager] ⇥⇥fontWithFamily: fontName ⇥⇥ traits: (bold ? NSBoldFontMask : NSUnboldFontMask) | (italic ? NSItalicFontMask : NSUnitalicFontMask) ⇥⇥ weight: 5.0f * font_weight / 100.0 ⇥⇥ size: (float)font_size]; ⇥NSMutableDictionary *attr = [NSMutableDictionary dictionary]; }
This approach guarantees that suff aligned at right or center will be more/less aligned well regardless of tab size.
Cheers,
- Is there an <a href... snippet, I can not find it
cntrl-shift-L will wrap things in link syntax, otherwise make a tab snippet for "href"
2) How can I shift selected text right and left one space at a time? Not to my knowledge: I made one for wikidot.tmBundle - maybe steal that command
3) Most other apps allow me to drag and drop a text clipping to the apps icon, and it will open it. In TM, I have to open the clipping, copy, then new file, then paste. Any workarounds on this one? Oddly, I find I used this feature a lot and I am missing it.
Along with dragging files to documents to insert their path... missing features...
* I am often opening tab separated files, and will need to open tabs to 40 spaces
Big drag for me too: It is not possible to have variable tab stops - a really nice feature would be for tabs to learn the desired per-column width from the contents of the first line, but that feature is not implemented.
5) Given code such as: $foo = 'bar'; $this = 'that';
This didn't come through email very well: I assume you want to align on '='?
cmd-shift-right arrow
6: I'd be interested in a vblog entry on the sql bundle too
On Mar 24, 2009, at 4:01 PM, Timothy Bates wrote:
- Is there an <a href... snippet, I can not find it
cntrl-shift-L will wrap things in link syntax, otherwise make a tab snippet for "href"
Thanks. Not quite how I want it to work, I will look at how to make a snippet.
- How can I shift selected text right and left one space at a time?
Not to my knowledge: I made one for wikidot.tmBundle - maybe steal that command
This one does not seem to work for me, insets by a tab stop.
- Given code such as:
$foo = 'bar'; $this = 'that';
This didn't come through email very well: I assume you want to align on '='?
cmd-shift-right arrow
Can you tell me what bundle this is, I get nothing on that sequence.
Thanks for the pointers. -- Scott * If you contact me off list replace talklists@ with scott@ *
- How can I shift selected text right and left one space at a time?
Not to my knowledge: I made one for wikidot.tmBundle - maybe steal that command
This one does not seem to work for me, insets by a tab stop.
the wikiDot command is scoped for wikiDot text. So you would copy it, and set the scope the plain text, and assign a key-command to trigger it.
align on '='?
cmd-shift-right arrow
Can you tell me what bundle this is, I get nothing on that sequence.
sorry: cmd-option-]
it's in the Source bundle
I just discovered that if you drag a photo from the Finder into TM, you will get a complete img tag, with height and width and alt and everything just so. Edit the path to match your server root, and it Just Works(tm).
Walter
On Mar 24, 2009, at 4:41 PM, Scott Haneda wrote:
- Any of you care to share your top #1 little tricks, the one thing
you use all the time, that just makes you happy every time you invoke it? I mainly work in php, so leaning on things that would be helpful in that area would be nice.
You can edit that behavior in the Bundle Editor, too, if you want to include the slash before the closing bracket, as is required by XHTML.
So instead of this:
<img src="... >
You get
<img src="... />
On Wed, Mar 25, 2009 at 1:28 PM, Walter Lee Davis waltd@wdstudio.com wrote:
I just discovered that if you drag a photo from the Finder into TM, you will get a complete img tag, with height and width and alt and everything just so. Edit the path to match your server root, and it Just Works(tm).
Walter
On Mar 24, 2009, at 4:41 PM, Scott Haneda wrote:
- Any of you care to share your top #1 little tricks, the one thing
you use all the time, that just makes you happy every time you invoke it? I mainly work in php, so leaning on things that would be helpful in that area would be nice.
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
In TM's Advanced preferences, in the Shell Variables segment, add a new variable named TM_XHTML with the value of / (single slash) and you will get this trailing slash everywhere you use a singleton tag, without editing any of the snippets.
Walter
On Mar 25, 2009, at 1:54 PM, Chip Cullen wrote:
You can edit that behavior in the Bundle Editor, too, if you want to include the slash before the closing bracket, as is required by XHTML.
This is just an amazing tip, I was just going through and editing a ton of snippets, now I do not have to. Thanks!
On Mar 25, 2009, at 10:59 AM, Walter Lee Davis wrote:
In TM's Advanced preferences, in the Shell Variables segment, add a new variable named TM_XHTML with the value of / (single slash) and you will get this trailing slash everywhere you use a singleton tag, without editing any of the snippets.
Walter
On Mar 25, 2009, at 1:54 PM, Chip Cullen wrote:
You can edit that behavior in the Bundle Editor, too, if you want to include the slash before the closing bracket, as is required by XHTML.
-- Scott * If you contact me off list replace talklists@ with scott@ *
Is there a native way to do brace reformatting? I believe it is called "cuddling". I often pull a function from here or there, and the formatting is not to my liking...
function { # code }
versus
function { # code } -- Scott * If you contact me off list replace talklists@ with scott@ *
Scott Haneda wrote:
Is there a native way to do brace reformatting? I believe it is called "cuddling". I often pull a function from here or there, and the formatting is not to my liking...
function { # code }
versus
function { # code }
Should be something like
ruby -0777 -p -e '$_.gsub!(/\n\s*{/ {/)'
or, if you really want to go the other way (:-)), you don't need multi-line matching and can do it right in TextMate, substituting
^(\s*)(\S.*)\s*{\s*$
with
$1$2\n$1{
(I even tested that. It works on your example, which is a start.)
Christopher
On Apr 30, 2009, at 11:29 AM, Christopher Creutzig wrote:
Should be something like
ruby -0777 -p -e '$_.gsub!(/\n\s*{/ {/)'
or, if you really want to go the other way (:-)), you don't need multi-line matching and can do it right in TextMate, substituting
^(\s*)(\S.*)\s*{\s*$
with
$1$2\n$1{
(I even tested that. It works on your example, which is a start.)
Would you mind explaining how to do this in a bundle, I copied the first example above, and but a ruby shebang in a bundle command, set the scope to source.php. I get a lot of errors when I run it.
Thanks
Scott Haneda wrote:
Would you mind explaining how to do this in a bundle, I copied the first example above, and but a ruby shebang in a bundle command, set the scope to source.php. I get a lot of errors when I run it.
#! /usr/bin/env ruby puts STDIN.gets(nil).gsub(/\n\s*{/, " {")
Christopher
Scott Haneda talklists@newgeo.com wrote (Thu, 26 Mar 2009 05:13:06 -0700):
Is there a native way to do brace reformatting? I believe it is called "cuddling". I often pull a function from here or there, and the formatting is not to my liking...
function { # code }
versus
function { # code }
I tried to do this using regular expressions, too, but I kept failing. Maybe there _is_ an easier solution, but here is what works great for me:
I downloaded Beautify PHP from http://www.bierkandt.org/beautify/
Then I added a Bundle Command in TextMate with: ---------- Save: Nothing Command(s): php /path/to/beautify_php -v 0 -l -b 1 Input: Selected Text or Document Output: Replace Selected Text ----------
Note that the correct file is "beautify_php", NOT "beautify_php.php" (which is also contained in the Beautify PHP package). And of course you might want to change the parameters given in the command line.
Kind regards, Tobias Jung
On May 2, 2009, at 7:01 AM, Tobias Jung wrote:
I tried to do this using regular expressions, too, but I kept failing. Maybe there _is_ an easier solution, but here is what works great for me:
I downloaded Beautify PHP from http://www.bierkandt.org/beautify/
Then I added a Bundle Command in TextMate with:
Save: Nothing Command(s): php /path/to/beautify_php -v 0 -l -b 1 Input: Selected Text or Document Output: Replace Selected Text
Note that the correct file is "beautify_php", NOT "beautify_php.php" (which is also contained in the Beautify PHP package). And of course you might want to change the parameters given in the command line.
Excellent, thanks! This is perfect. I could not get it to work at first, I had to set the scope in the bundle item, then I was fine. Thanks for the suggestion.