Return shortcut to escape formatting environment
This is a bit of a two-purpose post in that I was looking for a way to do the following, and stumbled across something that looks like a potentially deleterious quirk in the text engine while trying different keystrokes.
Firstly the suggestion: something a number of coding and Markdown text editors do is allow for a modified Return key to escape the current auto-formatting environment. For example if I am typing in an unordered list, then something like ⇧↩ could put me on the next line without any bullets or tab indents. It’s just a nice little convenience that works in a universal fashion, no matter the cursor context. There are ways of doing it, like ↩ + ⌘delete, but like I say, it’s more about keeping text entry feeling fluid rather than having to take multiple steps to do what you want.
So while I was looking for an existing shortcut, I tried ⇧⌃↩ and ended up with an odd character being inserted (u+0080, which it seems word processors use as a line break). I’m not actually sure if that has any utility in a plain-text file. But can do funny things with the formatting (try adding one to the end of a list line and then pressing tab). It’s not something peculiar to your code—TextEdit does the same thing—so maybe it should be left alone. But I figured you might at least want to make sure the formatter works properly around it.
If it is a pest that shouldn’t be in a plain-text editor, maybe that shortcut could be used for something cooler, like the above suggestion. :)
-
I'm not sure about the keystroke causing u+0080 -- that is apparently created by macOS. I'm not messing with it. ;)
As for the original suggestion -- you can already do that by just hitting return again. All (to my knowledge) of the automatic formatting applied with return functions is escaped by one "level" when you hit return again without adding anything else. This is true with indents, lists, tables, etc. One advantage of this is that you can quickly outdent by a one (or more) level(s) in a nested list.
0 -
There are cases where the successive-return method doesn't work as well---like you say it works as an outdent tool (which doubles as cancellation for simple environments), but by that very token it doesn't work as well as a full cancellation tool in a swift and consistent form. Escaping out of a four level deep list for example takes five return key hits to get all the way out, so you're having to react to the software in real time rather than just issuing a single command and having the software react to you. Given that, as a global "I want nothing" action, `↩ + ⌘delete` is more consistently effective from those grounds.So that's what I think this common approach is striving toward: something predictable and simple to execute, in that it uses a key we already use heavily for the same basic purpose. `⌥↩` also fits in with the natural notion of altering the base command to an optional/alternative outcome.0
-
Oh! Something I forgot to add here, but another common convention among text editors is that this type of command also be something that moves to a new line no matter where the cursor position is on the current line. Where regular Return would split the line into two, a modified return would create a new line (with no attachments) below the current one without disturbing the original line.
Very useful if you get used to having it; the kind of thing that becomes second nature as just don't have to worry about little things like where the cursor is.
0 -
Another scenario where ignoring the auto-correction/etc. engine is useful, is when you want to have what is on the current line left alone. There are some conditions where when you press Return, the editor cleans up what was on the previous line before moving you to the next. This is in fact one of the things you mentioned as a better way to do this---to press return on a line with nothing but a bullet to escape the environment.
But what is what you really want is to leave the empty bullet line alone and move to an empty line below it? To be fair, in that specific case there isn't much utility to wanting to do that, but here is for example is how I like to format quotes:
```
> > Nested quotation paragraph
>
> Paragraph one...
>
> Paragraph two...
```And, as far as I understand it, this method produces a better, more semantically cohesive result than leaving empty lines between the quoted marked lines. One ends up with a sequence of discrete blockquote environments rather than a single block quote with one nested blockquote and two separate paragraphs all within the single container.
With a key to override all applicable return behaviours and simply insert a newline, one could much more simply compose an extended quotation like the above.
To reiterate, it is less about specific scenarios where it would be useful to use, because although they are not common, they are very diverse, and once you can do it, it becomes more common to make use of such a capability, as a fluid and intuitive way of escaping any environment behaviour the cursor position would currently trigger, from wherever the cursor is within the line.
0
Please sign in to leave a comment.
Comments
4 comments