[TxMt] Looking for the equivalents to some Emacs commands
joe.thornber at gmail.com
Sun Aug 6 11:15:01 UTC 2006
On 06/08/06, Jonas Steverud <jtvrud at bredband.net> wrote:
> 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.
> 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.
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.
txt = STDIN.read
index = ENV['TM_LINE_INDEX'].to_i
print txt.slice(0, index).rstrip
print " "
print txt.slice(index, txt.length - index).lstrip
print txt.gsub(/[ \t]+/, ' ')
Selected Text or Line
Replace Selected Text
More information about the textmate