Dear Textmaters,
I'm a very unsophisticated Textmate-lover who upgraded recently to Textmate 2.
In Textmate 1.X I'd made some macros to jump to the beginning or end of a sentence while editing text. Basically, they just search backward or forward for a gerrymandered regex and move the cursor to the position of the first match.
Now, when I imported these macros into Textmate 2, the jump-forward macro works fine. But, the jump-backward macro behaves like the jump-forward macro. I.e., when I run it, it seems to do "find next" rather than the requested "find previous".
The code is pasted below.
If anybody could suggest an explanation or remedy I'd appreciate it!
Thanks,
Max
( { argument = { action = 'findPrevious'; findInProjectRegularExpression = :false; findString = '\S'; ignoreCase = :true; regularExpression = :true; replaceAllScope = 'selection'; replaceString = ''; wrapAround = :false; }; command = 'findWithOptions:'; }, { argument = { action = 'findPrevious'; findInProjectRegularExpression = :false; findString = '((?|.|!)(''|"|)|}|])*(\n|\t|\r|\s)+)|((\r|\n)\s)'; ignoreCase = :true; regularExpression = :true; replaceAllScope = 'selection'; replaceString = ''; wrapAround = :true; }; command = 'findWithOptions:'; }, { command = 'moveRight:'; }, )
On Jun 8, 2013, at 1:10, Max Weiss 30f0fn@gmail.com wrote:
Now, when I imported these macros into Textmate 2, the jump-forward macro works fine. But, the jump-backward macro behaves like the jump-forward macro. […] If anybody could suggest an explanation or remedy I'd appreciate it!
The “search backward” macro action was treated as a forward search. I have corrected that in a test build that you can obtain by holding option while clicking Check Now in Preferences → Software Update.
You may however need to modify the macro as shown below to work when already at a start of a sentence. This has to do with how “find previous” will now allow the found range to extend to the right of the caret, which 1.x didn’t do. I don’t like this behavior, but it’s presently handled by the regexp library, so it might take a while before I get around to changing it.
I btw simplified the regular expression, it should still do the same.
( { command = 'moveLeft:'; }, { command = 'moveLeft:'; }, { argument = { action = 'findPrevious'; findString = '[?.!][''")}]]*\s+|\n\s'; regularExpression = :true; }; command = 'findWithOptions:'; }, { command = 'moveRight:'; }, )