Is there an "Go to last edit" keyboard shortcut, or a way to create one in TextMate?
Essentially, the idea is that when editing a file, I often move around in the file to check other things and then want to come back to the place I was editing to continue what I was doing. Now I have to remember to add a bookmark, before navigating around, then find that bookmark, and remove it, which is a bit cumbersome.
Alex
----- Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise Orbeon's Blog: http://www.orbeon.com/blog/ Personal Blog: http://avernet.blogspot.com/ Twitter - http://twitter.com/avernet
On 16 Oct 2009, at 15:01, Alessandro Vernet wrote:
Is there an "Go to last edit" keyboard shortcut, or a way to create one in TextMate?
A side effect of Undo is that the cursor jumps back to the position of the edit. So a cheesy way to get the functionality you want is to hit Undo then Redo. You could bind that to a macro command if you want it as a single keystroke.
Steve,
Steve King-8 wrote:
A side effect of Undo is that the cursor jumps back to the position of the edit. So a cheesy way to get the functionality you want is to hit Undo then Redo. You could bind that to a macro command if you want it as a single keystroke.
It is funny that you should suggest that, because I tried doing *exactly* that this morning. Unfortunately while doing undo/redo "by hand" works fine, creating a macro that runs those commands doesn't do anything for me.
Here is the macro I recorded: http://www.nabble.com/file/p25932786/Go%2Bto%2Blast%2Bedit.tmMacro Go+to+last+edit.tmMacro Can see anything wrong with it?
Alex
----- Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise Orbeon's Blog: http://www.orbeon.com/blog/ Personal Blog: http://avernet.blogspot.com/ Twitter - http://twitter.com/avernet
Alessandro Vernet wrote:
It is funny that you should suggest that, because I tried doing *exactly* that this morning. Unfortunately while doing undo/redo "by hand" works fine, creating a macro that runs those commands doesn't do anything for me.
Here is the macro I recorded: http://www.nabble.com/file/p25932786/Go%2Bto%2Blast%2Bedit.tmMacro Go+to+last+edit.tmMacro Can see anything wrong with it?
Anybody has an idea about this one?
Alex
----- Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise Orbeon's Blog: http://www.orbeon.com/blog/ Personal Blog: http://avernet.blogspot.com/ Twitter - http://twitter.com/avernet
On 25 Oct 2009, at 13:51, Alessandro Vernet wrote:
Alessandro Vernet wrote:
It is funny that you should suggest that, because I tried doing *exactly* that this morning. Unfortunately while doing undo/redo "by hand" works fine, creating a macro that runs those commands doesn't do anything for me.
Here is the macro I recorded: http://www.nabble.com/file/p25932786/Go%2Bto%2Blast%2Bedit.tmMacro Go+to+last+edit.tmMacro Can see anything wrong with it?
Anybody has an idea about this one?
You're right, it looks like undo and redo can't be recorded in a macro. I tried editing the macro file by hand to add them, but no luck. Sorry, I don't have any other bright ideas.
On Oct 26, 2009, at 5:41 PM, Steve King wrote:
On 25 Oct 2009, at 13:51, Alessandro Vernet wrote:
Alessandro Vernet wrote:
It is funny that you should suggest that, because I tried doing *exactly* that this morning. Unfortunately while doing undo/redo "by hand" works fine, creating a macro that runs those commands doesn't do anything for me.
Here is the macro I recorded: http://www.nabble.com/file/p25932786/Go%2Bto%2Blast%2Bedit.tmMacro Go+to+last+edit.tmMacro Can see anything wrong with it?
Anybody has an idea about this one?
You're right, it looks like undo and redo can't be recorded in a macro. I tried editing the macro file by hand to add them, but no luck. Sorry, I don't have any other bright ideas.
Hi,
maybe try to record that macro :
ARROW_RIGHT → ARROW_LEFT ←
or create a new tmcommand in the Bundle Editor:
Input: None Output: Discard Command: open "txmt://open?line=$TM_LINE_NUMBER&column=$TM_COLUMN_NUMBER"
and bind it to any keystroke.
Cheers,
--Hans
On 25 Oct 2009, at 13:51, Alessandro Vernet wrote: You're right, it looks like undo and redo can't be recorded in a macro. I tried editing the macro file by hand to add them, but no luck. Sorry, I don't have any other bright ideas.
Well, I was trying to utilize AppleScript. I got a plain old script working:
tell application "System Events" tell process "TextMate" set frontmost to true keystroke "z" using {command down} keystroke "z" using {command down, shift down} end tell end tell
Assuming you have "Enable Access for Assistive Devices" turned on in the Universal Access pref pane.
I got it working from the Terminal:
osascript -e 'tell application "System Events" to tell process "TextMate" to set frontmost to true'; osascript -e 'tell application "System Events" to tell process "TextMate" to keystroke "z" using {command down}'; osascript -e 'tell application "System Events" to tell process "TextMate" to keystroke "z" using {command down, shift down}' (that's three commands all on one line...)
But putting that command into a TM Command doesn't seem to work. I'm far from a scripting expert, Apple- or Bash, so maybe it could work with more love. I've spent about as much time as I'm able to spend on such things, so hopefully someone else with more skills can take the idea?
Dru
On 26 Oct 2009, at 13:32, Dru Kepple wrote:
Well, I was trying to utilize AppleScript. I got a plain old script working: [...] But putting that command into a TM Command doesn't seem to work. I'm far from a scripting expert, Apple- or Bash, so maybe it could work with more love. I've spent about as much time as I'm able to spend on such things, so hopefully someone else with more skills can take the idea?
I took that idea and got it working with Butler. Butler is a hot-key manager / app launcher / kitchen sink, and is available from http://www.manytricks.com/butler/ . Anyway, with Butler it's trivial. Create a new Smart Item -> Keystrokes containing ⌘Z and ⇧⌘Z, assign it a hot key, and set "Only valid in..." to TextMate. Piece of cake.
Still no idea how to do it using only TextMate and what's natively installed.
Hi Steve,
Steve King-8 wrote:
I took that idea and got it working with Butler. Butler is a hot-key manager / app launcher / kitchen sink, and is available from http://www.manytricks.com/butler/ . Anyway, with Butler it's trivial. Create a new Smart Item -> Keystrokes containing ⌘Z and ⇧⌘Z, assign it a hot key, and set "Only valid in..." to TextMate. Piece of cake.
Awesome! And as a bonus, I get to discover Butler. This is quite a kitchen sink indeed, but it looks like a very powerful one.
Steve King-8 wrote:
Still no idea how to do it using only TextMate and what's natively installed.
Maybe for the next version of TextMate!
Alex
----- Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise Orbeon's Blog: http://www.orbeon.com/blog/ Personal Blog: http://avernet.blogspot.com/ Twitter - http://twitter.com/avernet
On 26 Oct 2009, at 22:25, Alessandro Vernet wrote:
Steve King-8 wrote:
Still no idea how to do it using only TextMate and what's natively installed.
Maybe for the next version of TextMate!
I think the undo/redo trick is a quite natural solution to the problem (but no, you can’t record undo/redo in macros for technical reasons).
Another solution is bookmarks (which have to be set explicitly with ⌘F2).
I am aware of the requests for an “last edit stack”, I am still undecided about whether or not to do one, regardless though, I expect 2.0 to be just the bare minimum to get it out the door, the extra features will have to come later (2.1, etc.)… people have been waiting for too long, I better not make them wait any longer than absolutely necessary ;)
I only can tell you again that my tiny macro (moveRight: moveLeft: moveRight: moveLeft:) works. (I do it twice only for refreshing the view port)
See attachment. Macro bound to ^⌥⌘→
Cheers,
--Hans
From: Hans-Jörg Bibiko
I only can tell you again that my tiny macro (moveRight: moveLeft: moveRight: moveLeft:) works. (I do it twice only for refreshing the view port)
I don't understand why that would work. If you've made an edit, then moved the cursor to another part of the document, how does this right/left macro bring you back to the point of the last edit?
(My hard drive died and I'm using a loaner computer without TextMate, or I'd try it myself.)
On Oct 16, 2009, at 9:01 PM, Alessandro Vernet wrote:
Essentially, the idea is that when editing a file, I often move around in the file to check other things and then want to come back to the place I was editing to continue what I was doing. Now I have to remember to add a bookmark, before navigating around, then find that bookmark, and remove it, which is a bit cumbersome.
I understood by "…move around…" scrolling to other places in the file WITHOUT moving the caret. By pressing ⇢ and ⇠ one scrolls back to the caret.
If you "move around" by using the caret then you can make usage of AppleScript (see also attachment):
Create a tmcommand:
Input: none Output: discard Command: cat <<-AS | iconv -f UTF-8 -t MACROMAN | osascript -- 2>&1 1>/dev/null tell application "TextMate" to activate tell application "System Events" to tell process "TextMate" to tell menu bar 1 to tell menu bar item "Edit" to tell menu "Edit" to click menu item "Undo" tell application "System Events" to tell process "TextMate" to tell menu bar 1 to tell menu bar item "Edit" to tell menu "Edit" to click menu item "Redo" AS
The iconv stuff is only needed to be compatible with Tiger.
One could speed up it by pre-compiling the AppleScript and run it.
Cheers,
--Hans
Or a bit faster is this tmCommand for MacOSX >= 10.5:
Input: none Output: discard Command: cat <<-AS | osascript -- tell application "System Events" tell process "TextMate" tell menu bar 1 tell menu bar item "Edit" tell menu "Edit" click menu item "Undo" click menu item "Redo" end tell end tell end tell end tell end tell AS
It won't be faster significantly if one pre-compliles it.
Cheers, --Hans
From: textmate-bounces+dru=summitprojects.com@lists.macromates.com [mailto:textmate-bounces+dru=summitprojects.com@lists.macromates.com] On Behalf Of Hans-Jörg Bibiko Sent: Wednesday, October 28, 2009 7:43 AM
Or a bit faster is this tmCommand for MacOSX >= 10.5:
Input: none Output: discard Command: cat <<-AS | osascript -- tell application "System Events" tell process "TextMate" tell menu bar 1 tell menu bar item "Edit" tell menu "Edit" click menu item "Undo" click menu item "Redo" end tell end tell end tell end tell end tell AS
It won't be faster significantly if one pre-compliles it.
_______________________________________________
From: textmate-bounces+dru=summitprojects.com@lists.macromates.com [mailto:textmate-bounces+dru=summitprojects.com@lists.macromates.com] On Behalf Of Hans-Jörg Bibiko
Command: cat <<-AS | osascript -- tell application "System Events" tell process "TextMate" tell menu bar 1 tell menu bar item "Edit" tell menu "Edit" click menu item "Undo" click menu item "Redo" end tell end tell end tell end tell end tell AS
_______________________________________________
For some reason this doesn't work for me. This is the same idea I was trying to get working, only I was using keystroke simulation. Is anyone else able to get this to work? I'm on 10.5.
(Sorry for me previously empty submission...I'm on a Windows box for my email. The keyboard shortcuts surprise me sometimes. Sucks.)
On Oct 28, 2009, at 4:37 PM, Dru Kepple wrote:
For some reason this doesn't work for me. This is the same idea I was trying to get working, only I was using keystroke simulation. Is anyone else able to get this to work? I'm on 10.5.
This should work if you did enable in System Preferences > Universal Access > "Enable access for assistive devices"
But you can try if the attached tmPlugin works for better and faster ;)
How to install: - quit TextMate - copy the plugin to ~/Library/Application Support/TextMate/PlugIns - launch TextMate - have a look at the the Main Menu > Navigation (last item)
I compiled it as 32bit Universal binary for MacOSX >= 10.5
Cheers,
--Hans
From: textmate-bounces+dru=summitprojects.com@lists.macromates.com [mailto:textmate-bounces+dru=summitprojects.com@lists.macromates.com] On Behalf Of Hans-Jörg Bibiko
This should work if you did enable in System Preferences > Universal Access > "Enable access for assistive devices"
But you can try if the attached tmPlugin works for better and faster ;)
--Hans
I do have the enable acces for assistive devices enabled; the command I was trying to write always worked when run from the terminal, but not from TextMate.
At any rate, the plugin works, and now it's as if it were part of TextMate to begin with! Very nice! You've been very helpful today, and it's not even 9 in the morning (where I live).
+dru
On Oct 28, 2009, at 4:55 PM, Dru Kepple wrote:
I do have the enable acces for assistive devices enabled; the command I was trying to write always worked when run from the terminal, but not from TextMate.
Which AppleScript did you use? Your approach by using "to keystroke" or my approach by using "click menu item"? The "keystroke" approach won't work due to the fact that one calls that applescript from inside TM. If one wants to remote TM from inside a bundle command one has to go via the GUI ie to simulate mouse click events. (I think)
At any rate, the plugin works, and now it's as if it were part of TextMate to begin with! Very nice!
If this plugin runs for other users as well and if it's useful then I can create a downloadable and improved version out of it (with menu validation etc.).
Cheers,
--Hans
From: textmate-bounces+dru=summitprojects.com@lists.macromates.com [mailto:textmate-bounces+dru=summitprojects.com@lists.macromates.com] On Behalf Of Hans-Jörg Bibiko
Which AppleScript did you use? Your approach by using "to keystroke" or my approach by using "click menu item"?
_______________________________________________
I tried both my original keystroke and your menu click versions. Neither worked. I'm not too sussed over it, since your plugin seems to work great. Might I inquire as to what went into creating it? I'm curious about this sort of stuff. I'd like to think that some day I, too, could maybe create a TextMate plugin.
+dru
Hans,
Hans-Jörg Bibiko wrote:
But you can try if the attached tmPlugin works for better and faster ;) [...]
The plugin works like a charm! I love it, thank you.
Alex
----- Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise Orbeon's Blog: http://www.orbeon.com/blog/ Personal Blog: http://avernet.blogspot.com/ Twitter - http://twitter.com/avernet
From: Allan Odgaard
I am aware of the requests for an "last edit stack", I am still undecided about whether or not to do one, [...]
A feature that I really loved in CodeWright (for Windows, now sadly discontinued) was that cursor movements would be placed in the undo stack along with edits. Move the cursor, and it was a simple undo operation to return to where you were. It also had a feature to compress multiple movements into a single undo item, so if you use the arrows to go up 10 lines it's a single undo to return to your last edit point.
CodeWright would also combine a continuous series of edits into a single undo item, so you didn't have to hold the undo key for a long time to get rid of your entire last change character by character.
On Oct 28, 2009, at 8:28 AM, King, Steven wrote:
From: Allan Odgaard
I am aware of the requests for an "last edit stack", I am still undecided about whether or not to do one, [...]
A feature that I really loved in CodeWright (for Windows, now sadly discontinued) was that cursor movements would be placed in the undo stack along with edits.
Way back then there was a fantastic editor for Atari ST/TT that had a similar feature. It was EXTREMELY useful, which is why I wrote a bundle emulating it for jEdit (my editor of choice before TM). I am disappointed that TM2 will not have it.
Gerd