Sublime Forum

Does Sublime Text 2 has this feature?

#1

Hello. I’m not sure how to call this feature but I really got used to it and would like to to know if its possible to get same behavior in Sublime Text 2. I’ll try to explain with images:

Can I make Sublime Text 2 behave like this? Thanks.

0 Likes

#2

Current behavior doing what? If you press up arrow at the end of the short line, the cursor will move like in your expected image. So I guess you mean something else.

0 Likes

#3

Did you mean something like that ?

0 Likes

#4

Sublime does behave like this already but only if you’ve placed the cursor at the end of line without using the END key. If you place the cursor with the mouse or the cursor keys, you’ll see the behaviour you want; if you hit END on the short line then hit Up, you’ll get the current behaviour which is to stick to the end of the (longer) line when you hit Up.

But you can get what you want by hitting END+CursorLeft+CursorRight before you hit Up. You can make this the default behaviour for the END key with the following…

  1. bind the above behaviour to the end key by creating a macro with the following code:

{"args": {"extend": false, "to": "eol"}, "command": "move_to"}, {"args": {"by": "characters", "forward": false }, "command": "move"}, {"args": {"by": "characters", "forward": true }, "command": "move"} ]

Save it in your Packages/User folder and call it “newend.sublime-macro”

  1. Then bind the macro to the END key by clicking “Prefs…Key Bindings - User” and add the following line
	{ "keys": "end"], "command": "run_macro_file", "args": {"file": "Packages/User/newend.sublime-macro"} }

You’ll need to add a comma to the end of the above line unless it’s the last or only keybinding line in the file. The line should be in-between the starting and ending ].

S

0 Likes

#5

[quote=“qgates”]Sublime does behave like this already but only if you’ve placed the cursor at the end of line without using the END key. If you place the cursor with the mouse or the cursor keys, you’ll see the behaviour you want; if you hit END on the short line then hit Up, you’ll get the current behaviour which is to stick to the end of the (longer) line when you hit Up.

But you can get what you want by hitting END+CursorLeft+CursorRight before you hit Up. You can make this the default behaviour for the END key with the following…

  1. bind the above behaviour to the end key by creating a macro with the following code:

{"args": {"extend": false, "to": "eol"}, "command": "move_to"}, {"args": {"by": "characters", "forward": false }, "command": "move"}, {"args": {"by": "characters", "forward": true }, "command": "move"} ]

Save it in your Packages/User folder and call it “newend.sublime-macro”

  1. Then bind the macro to the END key by clicking “Prefs…Key Bindings - User” and add the following line
	{ "keys": "end"], "command": "run_macro_file", "args": {"file": "Packages/User/newend.sublime-macro"} }

You’ll need to add a comma to the end of the above line unless it’s the last or only keybinding line in the file. The line should be in-between the starting and ending ].

S[/quote]

WOW! It worked, thanks a lot, you saved my day!

0 Likes