|
|
|
|
|
by TuringTest
1259 days ago
|
|
The origin text that you're cutting will have a precise syntax determining where the block starts and ends. Just copy it to the new position, and change the indentation level to that of the target position, maintaining the same block definition. You know, the same thing that would be done if there were start and end delimiters; because in Python, indentation changes ARE block delimiters, with a well-defined syntax. It's not rocket science, just following the language indentation rules for defining blocks. If the language parser can do it, why not the text editor? |
|
Will it? Are you sure?
> Just copy it to the new position, and change the indentation level to that of the target position, maintaining the same block definition.
"Just" copy. "Just" manually re-indent it.
Remember, we're talking about an IDE automatically figuring out proper indentation for something.
> If the language parser can do it, why not the text editor?
Because constructs that are valid from the compiler's point of view may be ambiguous fro the program's point of view: https://news.ycombinator.com/item?id=34235121