It's been a while since I last tooted (sorry, it was actually a tweet: https://twitter.com/watware/status/1135237918719696896) about my fluid structured programming experiments:
Tofu is now a VSCode extension which makes your keystrokes more meaningful while keeping their original intent. Your code is formatted after every change, which frees a lot of keys up to perform more useful actions.
The video shows what cursor movement and selection extending looks like. As you can see, the cursor skips over irrelevant parts of the code and selects parts that are only editable together. When extending a selection, Tofu selects the surrounding structure.
The mental model for extending selections, is also used for another key action:
Unwrap! I honestly cannot live without this one anymore, it is one of the quintessential code transformations, and our text editor paradigm requires an obscure sequence of actions to achieve the same result.
Of course there is also a wrap action. This one is more similar to what our editors offer out-of-the-box, where hitting ', [, { or ( wraps what is selected.
Bonus features are wrapping with functions, blocks, jsx elements and control structures (the first three are shown in the video).
"Horizontal" selection is also a bit different in Tofu. Within strings or identifiers it is still character-wise but otherwise it selects neighbors at the same level of structure.
This is helpful when moving several statements around or deleting multiple elements within a collection.
You can also select "quasi neighbors" which is useful for a special action, which is...
...reparenthesisation! A bit of a mouthful, I'm open to suggestions. Reprecedencisation is more semantic, but it is probably the most cursed concatenation of syllables I've ever typed (and I am german, so...).
Aaanyway, I love this action, despite it being a tad more nichey. Changing precedence in complex heavily-parenthesized expression can turn into a game of where-is-waldo, so this helps a lot in those situations.
Another essential one: With a single keystroke you can move statements, expressions and even swap operands.
The best code is the one you did not have to write, the second best is the one you get to delete. Tofu takes the context of your deletion into account and deletes connected pieces of syntax.
Last, but not least, there are a number of contextual actions, some of them shown in this video. My hope is that one intuitively runs into them, and I am sure there are many more one could add. Again, open to suggestions!
And that's it for now. You can install Tofu from VSCode's marketplace: https://marketplace.visualstudio.com/items?itemName=watware.tofu-vscode
I still call it an experiment, since there are a good number of rough edges still and it is NOT performant. If you want to read more background, caveats and all, here are my long-form ramblings: https://dflate.io/state-of-tofu
I've been busy building a subset of Tofu with none of the caveats. Read more about it over here:
https://dflate.io/vscode-soy