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