Home Download Buy Blog Forum Support

"Smart" horizontal cursor positioning

"Smart" horizontal cursor positioning

Postby jburnett on Wed Jul 27, 2011 9:26 pm

Hello,

Just came across Sublime, and it looks awesome :). I'm in the first day of playing with it, and am seeing no reason not to switch and buy at this point. One thing that I *am* missing from my previous editor (Textpad), that I havne't seen anywhere else, is the way cursor movement is handled when switching lines. It's a bit hard to describe, but it is *very* handy. I'll try to describe it below, but it's probably easier if you follow along by trying firsthand by downloading Textpad 4.x (e.g. http://www.textpad.com/download/v47/txpeng473.exe).

For example, say I have the following two lines, with the cursor positioned at the pipe:

Code: Select all
  The quick | fox jumped
  over the lazy dog.


...and then I typed "brown", the cursor would end up here:

Code: Select all
  The quick brown| fox jumped
  over the lazy dog.


...in most editors (including Sublime), if I then pressed the down arrow, I'd wind up with this:

Code: Select all
  The quick brown fox jumped
  over the lazy d|og.


However, Textpad ends up with this:

Code: Select all
  The quick brown fox jumped
  over the l|azy dog.


This comes in *very* handy when doing multiple similar edits across multiple lines.

It seems the editor is keeping track of both the cursor's "current X position" and the "base X position", which is "the original X position before any editing occurred since the last horizontal cursor navigation command". Then, if you move the cursor up or down (with either up/down arrows, or pgup/pgdn), the cursor tries to keep as close to the original X position as possible, but within the current line's constraints. The base X position is updated next time you manually position the cursor horizontally (e.g. left/right arrows, mouse click, etc).

Anyway, like I said, it's hard to appreciate without trying, and it'd be awesome to see added to what already looks to be a great editor.
jburnett
 
Posts: 89
Joined: Wed Jul 27, 2011 9:23 pm

Re: "Smart" horizontal cursor positioning

Postby Kronuz on Thu Jul 28, 2011 3:12 am

I had never seen this in any editor, though I can see the use in that behavior as I've encountered that many times, in which I wished the editor worked in precisely that way.
Kronuz
 
Posts: 98
Joined: Mon Feb 14, 2011 3:14 pm

Re: "Smart" horizontal cursor positioning

Postby adzenith on Thu Jul 28, 2011 5:22 pm

It sounds like the sort of feature that would take me a little while to get used to, but then which I'd be unable to live without forever after... kind of like multiple selections.
adzenith
 
Posts: 1214
Joined: Mon Oct 19, 2009 9:12 pm

Re: "Smart" horizontal cursor positioning

Postby jburnett on Fri Jul 29, 2011 1:14 am

Sidenote - please upvote :) - http://sublimetext.userecho.com/topic/4 ... sitioning/
I'm honestly not sure if this is the place to track the issue, or if the userecho place is....
jburnett
 
Posts: 89
Joined: Wed Jul 27, 2011 9:23 pm

Re: "Smart" horizontal cursor positioning

Postby PeterH on Fri Sep 16, 2011 11:49 am

I too have migrated from Textpad - there are only 2 features I still miss after 4 months - this one and the ability to simply find and replace using the current selection as the target.
PeterH
 
Posts: 4
Joined: Wed Jun 15, 2011 6:32 am

Re: "Smart" horizontal cursor positioning

Postby jbjornson on Fri Sep 16, 2011 12:25 pm

sublimator wrote:Can anyone show a screenie of that?

I don't have OSX else I'd download it.


It is a windows app.
jbjornson
 
Posts: 348
Joined: Tue Oct 27, 2009 4:25 pm
Location: Zurich, Switzerland

Re: "Smart" horizontal cursor positioning

Postby bizoo on Mon Oct 08, 2012 3:04 pm

Last year, found the idea interesting and try to implement it with the limited ST2 API, result:
A nightmare and nothing really useful.

But thinking it again last week and found a better way to do it:
Put the cursor back to the first edit position of the line BEFORE running the move command.
Still a nightmare with the actual ST2 api events, but works pretty well in most case.
And found it pretty useful.

Get it at https://github.com/bizoo/SmartCursor and add some keybindings to your user file based on the Example.sublime-keymap.

As I actually never try an editor with this behavior, feedback are welcomed.
bizoo
 
Posts: 879
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: "Smart" horizontal cursor positioning

Postby adzenith on Mon Oct 08, 2012 7:26 pm

I'm trying it out! I'll let you know how I like it.
Thanks!
adzenith
 
Posts: 1214
Joined: Mon Oct 19, 2009 9:12 pm

Re: "Smart" horizontal cursor positioning

Postby bizoo on Tue Oct 09, 2012 8:09 am

adzenith wrote:I'm trying it out! I'll let you know how I like it.
Thanks!

Thanks for trying it.

I pushed a small modification a few minutes ago.

Currently, IMHO, the only thing that doesn't work as expected is when your starting edit point is beyond the end of the line when you move the cursor, as when you remove the end of a line using DEL key.
As this plugin put the cursor(s) back to the start edit position before moving it, there's no way to do it with the current API.

If ST2 had virtual space (http://www.sublimetext.com/forum/viewtopic.php?f=4&t=805&start=0&hilit=virtual+space), this will not be an issue.
But it looks like virtual space potentially break most of the current API, or lot of new methods need to be added to deal with it.
bizoo
 
Posts: 879
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: "Smart" horizontal cursor positioning

Postby adzenith on Tue Oct 09, 2012 5:32 pm

Just had this thing fire for the first time while I was editing just now, and it turned out to be really awesome. Thanks!
adzenith
 
Posts: 1214
Joined: Mon Oct 19, 2009 9:12 pm

Next

Return to Ideas and Feature Requests

Who is online

Users browsing this forum: No registered users and 15 guests