Home Download Buy Blog Forum Support

Does Sublime Text 2 has this feature?

Does Sublime Text 2 has this feature?

Postby GhostBear on Mon Nov 26, 2012 3:40 pm

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:

Image

Can I make Sublime Text 2 behave like this? Thanks.
GhostBear
 
Posts: 2
Joined: Mon Nov 26, 2012 3:25 pm

Re: Does Sublime Text 2 has this feature?

Postby svenax on Mon Nov 26, 2012 3:59 pm

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.
svenax
 
Posts: 152
Joined: Tue Dec 20, 2011 12:47 pm

Re: Does Sublime Text 2 has this feature?

Postby Kwelity on Mon Nov 26, 2012 4:02 pm

Did you mean something like that ?

viewtopic.php?f=2&t=7308
Sorry for my english :)
Kwelity
 
Posts: 7
Joined: Fri Oct 05, 2012 8:50 am

Re: Does Sublime Text 2 has this feature?

Postby qgates on Mon Nov 26, 2012 4:12 pm

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:

Code: Select all
[
   {"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"

2. Then bind the macro to the END key by clicking "Prefs..Key Bindings - User" and add the following line

Code: Select all
   { "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
qgates
 
Posts: 223
Joined: Mon Nov 05, 2012 4:33 pm

Re: Does Sublime Text 2 has this feature?

Postby GhostBear on Mon Nov 26, 2012 7:14 pm

qgates wrote: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:

Code: Select all
[
   {"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"

2. Then bind the macro to the END key by clicking "Prefs..Key Bindings - User" and add the following line

Code: Select all
   { "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

WOW! It worked, thanks a lot, you saved my day!
GhostBear
 
Posts: 2
Joined: Mon Nov 26, 2012 3:25 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 19 guests