Sublime Forum

How: Cursor beyond end-of-line?

#1

Hi all, I’d appreciate if someone could tell me if Sublime has a mode, plugin or whatever, in which the cursor/caret can move beyond end-of line, primarily when arrow-keying the cursor vertically.

That is to say, if the cursor starts at horizontal position say 50, as I arrow up or down I don’t want the cursor to be forced leftward to the end of lines which are shorter than 50. (As a subsidiary point, if I start typing at the beyond-end-of line position, the editor should insert spaces to that point.) This behavior is an edit mode available in several editors I use, and I can’t work efficiently without it.

FWIW, this other post relates to this same feature: https://forum.sublimetext.com/t/small-feature-request/4353/1
but I didn’t see a reply.

Thanks,

Graham

1 Like

#2

What you’re asking for is Virtual space, something that I love too and grew very accustomed to back in the days of Brief and my current “other” editor, Crisp.

Vote it up here:
sublimetext.userecho.com/topic/8 … ite-space/

We need this because it makes in-line commenting a breeze (something that is valuable from time to time), facilitates column selection, copying and insertion to arbitrary places in the text, and is very handy for working with certain other kinds of text files. When your used to that freedom, the current paradigm feels very constraining, and I still go back to other editors when needed to use this facility.

Done intelligently, it would fill whitespace to the left with spaces where there is text on the line to the left, and tabs (and extra spaces if necessary) where the line is empty if the editor is using tabs as its primary indenting whitespace.

That, along with definable tabstop positions, are my biggest headaches with Sublime. Definable tabstops are needed to allow the above intelligent virtual space behaviour. In Brief I could set tabstops to “5 20 24”, which would set tabstops at those columns and the remaining tabstops would repeat the distance of the last two (28, 32, 36 etc).

The trouble with Sublime is that while it’s nice for editing “modern” languages like PHP and JS, it’s a PITA for working with older languages or other “programmer” text files, for example Windiff output (which tabulates varying-length filename and file CRCs). A file thats been edited by another developer with a a particular IDE/language that prefers tabs and particular tabstops (COBOL being a good example) cannot be brought into Sublime looking right. The usual reason is that tabstops cannot be defined; were that the case, you could load up a file with correct tabstops and everthing looks dandy. The perfect editor should be a one-stop for everyone’s editing requirements, and for now I have to drive two editors for my programming needs.

FichtFoll’s suggestion on userecho to implement virtual space as a plugin is a possibility. The methodology is to append lots of whitespace to the end of each line in a file, allow “free editing”, then trim trailing whitespace on save. But this is less than ideal for several reasons:

  1. Inability to distinguish virtual space from real space (Brief does this by allowing the cursor to change over virtual space - lovely!)
  2. Time to append and strip extra whitespace on load (or “start editing virtually”) and save with extremely large files
  3. Inability to support the above-mentioned intelligent behaviour when the user prefers tabs for a given filetype

I hope Jon’s considering this.

0 Likes

#3

Thanks qgates for your reply, that’ll save some time looking for a solution. FWIW, I myself don’t have a pressing need for the individually settable tabstops you mention, I mainly want virtual space for less-distracting and entirely predictable arrow-key navigation.

Not having virtual space capability is a fairly serious deal for me. Sure I can work without it, but it’s higher friction. (And I certainly expect there to be varying experiences and preferences on this point.)

For what it’s worth, Visual Studio, Embarcadero’s IDEs, EditPad and Notepad++ all have optional virtual space behavior. As far as I can see, Eclipse and NetBeans do not, and it’s partly because of those last two not having it that I’m on the lookout for clever editors, especially cross-platform ones (which EditPad and Notepad++ are not).

Sigh. OK, I’ll add a vote on userecho, but with 3289 issues over there, and this one approximately 95th on the list, it’s hard to see how this is going to get done :frowning:.

0 Likes

#4

Oh, and I forgot to mention – yes, Brief was a lovely editor, for its day!

0 Likes

#5

A plugin for virtual space when using the arrow keys to move would be extremely easy. I think we’d need editor support to do it with the mouse.

0 Likes

#6

You can override the “run_” method of commands to grab the mouse event params when called from a mouse binding. This could be used with layout and something to translate it into buffer coordinates and then you’ll be able to fill remaining stuff with spaces. I didn’t test it but according to what I grabbed up in the time I wrote some packages this should be possible.

0 Likes

#7

Translating it into buffer coordinates is the hard part…

0 Likes

#8

After experimenting with viewports and layouts (and ther vectors respectively) it seems that these vectors have pixels as their base dimension and just support floating numbers with them. However, the x and y positions from the mouse event seem to be relative the the client and the viewport vectors relative to the, well, viewport. This get’s complicated when the menu is visible or tabs are visible or the sidebar and results in various desyncs.

So, at least with the current API it seems not possible (though, I didn’t really spend much time on it).

0 Likes

#9

“Kludges” in the area of appending EOL whitespace to implement virtual space will play havoc with using copy and paste when not across line boundaries. I did think about implementing this myself a while ago, but for the reasons above it just seemed fairly pointless.

Especially as I remember at some point in the past Jon alluding to a proper implementation of this being on the roadmap for Sublime.

0 Likes

#10

I’m making the movie to ST from Crisp myself, but it’s going to be a battle, as I’ve been using Crisp for 20 years. I already found Origami (for fast splitting control with keyboard). As we seem to be the only two Crisp users here, do you have any tips or tricks to help make the transition to Sublime smoother? I was considering making a “Sublime for Crisp Users” thread to keep track of such things.

0 Likes

#11

Hello there,
I am trying this Sublime Editor in 2017 and first comment is… how can I have the cursor move vertically without going left or irght ? what is called above Virtual Space…
4 years after this original post is there anything about this ?
Thanks for anyone listening.

0 Likes

#12

you could presumably build a plugin to add whitespace after the end of the line up to the caret’s column position when you click on a line or move up and down, and remove it again when the caret moves back off the line if desired, though I haven’t read any of the preceding posts to see why you would want to do such a thing or if someone else make a plugin already


0 Likes

Virtual space