Hacker News new | ask | show | jobs
by rishflab 1443 days ago
Code can be parsed into an abstract syntax tree. Structural editing is editing code at the tree level. You probably already do it using expand/shrink selection.

If you have a selection eg. a node on this tree, expand selection would move up one level on this tree and select the higher node and everything underneath it.

You can play around with this concept here: https://tree-sitter.github.io/tree-sitter/playground. Click the blue elements in the tree section and see how it affects what is selected.

Now imagine a grammar/keymap which is optimized for traversing, selecting, mutating code at this level. I think this is the future, not the VIM grammar. Many IDE's already do this style of editing to an extent.