Hello, I am contemplating to buy TextMate, it is by far the most competent and well designed editor I've seen for OS X - and I've been looking for a replacement for Emacs for the last couple of years* - but before really hitting the credit card I would like to find the answer to a few questions that I have not found in the documentation:
1. A very handy feature of Emacs is the just-one-space command; that is, all spaces and tabs around the point is reduced into one space. E.g. (the bar sign is the cursor); "x | x" becomes "x |x". Is there such a command within TextMate? If not, any suggestions for how to create one? I did an experiment, I created a new command and had it running perl with a regexp on the line. The problem is that I want to have it to be run around the current position, not all spaces on the line. Is there a way of sending the current cursor position to the command? I.e. "x x | x" shall become "x x |x", not "x x |x" or something like it.
2. Indent region: Something that I frequently uses is the fill- paragraph and friends of Emacs; TextMate's Reformat (^Q) isn't as advanced and is not language/bundle aware. i was thinking of porting the Lisp code into e.g. perl and create a new command for it, but before I spend any time on it I would like to know if there is something similar already implemented that I've missed? (I usully write HTML, Shell Scripts and Perl in TextMate but will migrate my LaTeX files and other programming languages to TextMate as time passes.)
3. When I write HTML I would like to have e.g. lists looks like this: <ol> <li>AAA Lorem ipsum lorem ipsum lorem ipsum lorem ipsum BBB lorem ipsum lorem ipsum lorem ipsum lorem ipsum CCC lorem ipsum lorem ipsum lorem ipsum</li> </ol> But, I do not want it to add whitespace before the BBB and CCC, I would like it to wrap lines visually but the file should still look like this:
<ol> <li>AAA Lorem ipsum lorem ipsum lorem ipsum lorem ipsum BBB lorem ipsum lorem ipsum lorem ipsum lorem ipsum CCC lorem ipsum lorem ipsum lorem ipsum</li>
</ol>
Is this even possible? The visual presentation and the physical file would then differ and I don't think that makes sense for a /text/ editor. (This is not available in Emacs AFAIK but it is something that I miss.)
Thank you.
/Jonas ----- *) I'm fed up with the lack of proper Unicode support, no native Aqua build that isn't a hack and the reliance on X11 where cut-and-paste between X11 and any other OS X application s*cks. Don't get me wrong, I lived inside Emacs for over ten years, I not only read alt.religion.emacs - I also posted in it! When I say that TextMate is a competent editor, then it is far from an exaggeration. But I don't say that it is *the* editor. Not quite yet. :-)
Hello Jonas,
- A very handy feature of Emacs is the just-one-space command;
that is, all spaces and tabs around the point is reduced into one space. E.g. (the bar sign is the cursor); "x | x" becomes "x |x". Is there such a command within TextMate? If not, any suggestions for how to create one? I did an experiment, I created a new command and had it running perl with a regexp on the line. The problem is that I want to have it to be run around the current position, not all spaces on the line. Is there a way of sending the current cursor position to the command? I.e. "x x | x" shall become "x x |x", not "x x |x" or something like it.
An approach here is to record a Macro. Search and Replace the Regular Expression “(?<=\S)\s{2,}” with a single space (using the Previous Button, that is searching backwards). The Problem of this is that it will not match the current whitespace thingy when you are directly at the start of it. A pragmatic solution to this is to press `⌃F` before searching, and so moving the cursor one column to the right. Of course one could also do it with a Command and make use of `TM_INPUT_START_COLUMN` (see recent release notes of “Cutting Edge” Build 1200) to get the current caret position and start searching from there.
- Indent region: Something that I frequently uses is the fill-
paragraph and friends of Emacs; TextMate's Reformat (^Q) isn't as advanced and is not language/bundle aware. i was thinking of porting the Lisp code into e.g. perl and create a new command for it, but before I spend any time on it I would like to know if there is something similar already implemented that I've missed? (I usully write HTML, Shell Scripts and Perl in TextMate but will migrate my LaTeX files and other programming languages to TextMate as time passes.)
I haven't used emacs for quite some time now, but I remember using that command a lot as well, when TeXing. I think there might be some people interested to see this working for LaTeX so you might get help there. So this builtin Command would have to be overridden for specific Bundles (or all bundles depending on the Text Bundle) and could implement the logic needed.
- When I write HTML I would like to have e.g. lists looks like this:
<ol> <li>AAA Lorem ipsum lorem ipsum lorem ipsum lorem ipsum BBB lorem ipsum lorem ipsum lorem ipsum lorem ipsum CCC lorem ipsum lorem ipsum lorem ipsum</li> </ol> But, I do not want it to add whitespace before the BBB and CCC, I would like it to wrap lines visually but the file should still look like this:
<ol> <li>AAA Lorem ipsum lorem ipsum lorem ipsum lorem ipsum BBB lorem ipsum lorem ipsum lorem ipsum lorem ipsum CCC lorem ipsum lorem ipsum lorem ipsum</li>
</ol>
Is this even possible? The visual presentation and the physical file would then differ and I don't think that makes sense for a / text/ editor. (This is not available in Emacs AFAIK but it is something that I miss.)
There was some discussion about Soft Wrap indentation already. I think it is on the TODO List but you should not count on it to be implemented too soon. But generally, I don't understand why one would not want to insert a hard line break and some more whitespace in that case. HTML does not care about that whitespace at all (if it's not inside a preformatted block). When someone else looks at the source with a different Wrap Column Setting all he will see is little mess ;) But that's personal preference for you.
Have a nice day, Soryu
Hi Jonas,
On 06/08/06, Jonas Steverud jtvrud@bredband.net wrote:
Hello, I am contemplating to buy TextMate, it is by far the most competent and well designed editor I've seen for OS X - and I've been looking for a replacement for Emacs for the last couple of years* - but
I recently switched from Emacs and am enjoying TextMate a lot.
- A very handy feature of Emacs is the just-one-space command; that
is, all spaces and tabs around the point is reduced into one space. E.g. (the bar sign is the cursor); "x | x" becomes "x |x". Is there such a command within TextMate? If not, any suggestions for how to create one? I did an experiment, I created a new command and had it running perl with a regexp on the line. The problem is that I want to have it to be run around the current position, not all spaces on the line. Is there a way of sending the current cursor position to the command? I.e. "x x | x" shall become "x x |x", not "x x |x" or something like it.
I had a go at writing this for you, the only problem with it is that the cursor doesn't move, so if you've deleted a lot of whitespace you will find the cursor in one of the following words.
#!/usr/bin/env ruby
txt = STDIN.read if !ENV['TM_SELECTED_TEXT'] index = ENV['TM_LINE_INDEX'].to_i print txt.slice(0, index).rstrip print " " print txt.slice(index, txt.length - index).lstrip else print txt.gsub(/[ \t]+/, ' ') end
Command options: Selected Text or Line Replace Selected Text
- Joe
6 aug 2006 kl. 13.15 skrev Joe Thornber:
On 06/08/06, Jonas Steverud jtvrud@bredband.net wrote:
[...]
- A very handy feature of Emacs is the just-one-space command;
[...]
I had a go at writing this for you, the only problem with it is that the cursor doesn't move, so if you've deleted a lot of whitespace you will find the cursor in one of the following words.
Thank you, but since TextMate does not move the cursor, whichever implementation that is used is useless. :-(
I assume this could be solved with Applescript, depending on how scriptable TM is, but I don't think it is worth the effort at the moment.
(Alan, please consider this as a request for the possibility to move the cursor in a command - if no such feature exists that we have missed.)
Thanks for the feedback, I still consider the problems unsolved though (I haven't had time to test Soryu's solution to the first problem). :-)
/Jonas
PS. I maybe should mention why I would like the soft wrap; I have some files that consists of very long nested lists and this impact the file size quite a bit. I think, from the top of my head, that I could reduce the file size with about a kbyte for some of the files. Whitespace has value to me but as soon as the file leaves me, the whitespace gets a negative value. It is not worthless as it actually adds a price for the user - longer download time and larger caches. The price is low but it is not zero!
On 07.08.2006, at 21:46, Jonas Steverud wrote:
PS. I maybe should mention why I would like the soft wrap; I have some files that consists of very long nested lists and this impact the file size quite a bit. I think, from the top of my head, that I could reduce the file size with about a kbyte for some of the files. Whitespace has value to me but as soon as the file leaves me, the whitespace gets a negative value. It is not worthless as it actually adds a price for the user - longer download time and larger caches. The price is low but it is not zero!
Ah, I bet you need to make sure the website stays under 100kB even after adding a whooping 88kB of prototype.js. Yes, must be it ;)
Soryu.
On 07/08/06, Jonas Steverud jtvrud@bredband.net wrote:
6 aug 2006 kl. 13.15 skrev Joe Thornber:
On 06/08/06, Jonas Steverud jtvrud@bredband.net wrote:
[...]
- A very handy feature of Emacs is the just-one-space command;
[...]
I had a go at writing this for you, the only problem with it is that the cursor doesn't move, so if you've deleted a lot of whitespace you will find the cursor in one of the following words.
Thank you, but since TextMate does not move the cursor, whichever implementation that is used is useless. :-(
If you set 'Insert as Snippet' it moves the cursor.
- Joe
On 08/08/06, Joe Thornber joe.thornber@gmail.com wrote:
If you set 'Insert as Snippet' it moves the cursor.
oh, plus you need to replace the line: print " " with print " ${1}"
On 8/8/2006, at 14:14, Joe Thornber wrote:
On 08/08/06, Joe Thornber joe.thornber@gmail.com wrote:
If you set 'Insert as Snippet' it moves the cursor.
oh, plus you need to replace the line: print " " with print " ${1}"
Yes, inserting as a snippet and using the ability to put tab stops in the snippet is the recommended way to control the carets position.
I should add that when inserting as a snippet one should escape snippet control characters, I have attached an updated command which does that: