Has anyone had problems with pasting and indenting? I found a message from last october but no followup.
What happens is that whenever I paste code, things are "double" indented. For example, if I select, copy and paste just the 2 middle lines of the following...
1 def index 2 @todos = Todo.find(:all, :include => [:users, :job]) 3 render_partial_collection "todo", @todos 4 end
... I end up with this...
1 def index 2 @todos = Todo.find(:all, :include => [:users, :job]) 3 render_partial_collection "todo", @todos 4 @todos = Todo.find(:all, :include => [:users, :job]) 5 render_partial_collection "todo", @todos 6 end
Line #5 shouldn't be indented any more than line #6, yet it's indented with 2 additional tabs (or set of 4 spaces, doesn't matter which I use). That's not supposed to happen, right?
Using b12.
On Jun 10, 2005, at 17:20, Jack Baty wrote:
Line #5 shouldn't be indented any more than line #6, yet it's indented with 2 additional tabs (or set of 4 spaces, doesn't matter which I use). That's not supposed to happen, right?
The reason it changes the indent is because re-indent pasted text is enabled in the preferences.
As for your double-indent, the reason for that (i.e. the reason the re-indent of pasted text is not smart enough to do it right) is because you do not select from the beginning of line 2, but instead skip the two tabs.
So what you actually store on the clipboard is this:
@todos = Todo.find(:all, :include => [:users, :job]) render_partial_collection "todo", @todos
TextMate will then re-indent that to where you paste it, meaning inserting two tabs in front of _both_ lines.
I have on the to-do that it should store the current indent of copied text on the clipboard, which should solve this copy/paste pattern, but for now try to remember selecting from the beginning of the line when you do copy/paste, and I think you'll find it to work much better.
I have on the to-do that it should store the current indent of copied text on the clipboard, which should solve this copy/paste pattern, but for now try to remember selecting from the beginning of the line when you do copy/paste, and I think you'll find it to work much better.
Makes perfect sense. And you are right about copying from the beginning of the line. Works good enough for me, and I'll look forward to additional improvements. Thanks!
On 10-06-2005 20:36, Jack Baty wrote:
Makes perfect sense. And you are right about copying from the beginning of the line. Works good enough for me, and I'll look forward to additional improvements. Thanks!
And there's even a keyboard shortcut for you to make your life a bit easier: Shift-cmd-L selects the complete current line. And if you then hold the shift and press down or up arrow, you select the complete line below/above it... Really increased my speed with selecting blocks of code.
And there's more gems like this one in the Edit, Select submenu.
Jeroen.