If you make the status buffer editable (M-x read-only-mode
), you actually can edit it. Note, though, that this edits only the magit status buffer, and not the underlying file, and this is generally very hacky and it's easy to break the status buffer this way.
However, this can still be useful because you can then perform git operations on the edited diffs - e.g. you can edit a part of a diff, then select and stage the edited variant.
One particularly useful operation which can be done this way is to reorder lines to allow staging only some edits in consecutive edited lines. For example, if the old file is:
fun(apple);
bun(banana);
and it was changed to:
fun(apple2);
bun(banana2);
then the diff will be:
-fun(apple);
-bun(banana);
+fun(apple2);
+bun(banana2);
If you wish to stage only changes in the first line, staging only the -fun(apple);
and +fun(apple2);
lines will not do what you want - it will reorder the calls. However, by making the magit status buffer writable, you can reorder lines to make it look like this:
-fun(apple);
+fun(apple2);
-bun(banana);
+bun(banana2);
Then, you can select the first two lines and stage them, achieving the desired result.
RET
to jump to a buffer within Emacs in which you can edit the file.