Little Emacs Tricks #2
Emacs sometimes surprises me with wonderful little features.
Today, I realized the power of "undo in region".
If you remember you had made a change on a section of a file, but don't want to undo all the changes you've just been working on, mark a region and C-_ till you get what you're looking for. Until you unmark the region, it will only undo actions that affect that particular region.
This is particularly useful when working in large class files with many methods, or huge javascript files with too many functions. You can highlight a function, undo the changes you made half an hour ago, and continue on, without having to go redo the changes in between.
For instance, I was working on a heavily documented file, and realized I had accidentally deleted the Javadoc in one section of the file. I had done this a long time ago. I selected the lines where the Javadoc used to be, C-_, and boom, there it was, without affecting anything else in the document.
Wonderful stuff.
Today, I realized the power of "undo in region".
If you remember you had made a change on a section of a file, but don't want to undo all the changes you've just been working on, mark a region and C-_ till you get what you're looking for. Until you unmark the region, it will only undo actions that affect that particular region.
This is particularly useful when working in large class files with many methods, or huge javascript files with too many functions. You can highlight a function, undo the changes you made half an hour ago, and continue on, without having to go redo the changes in between.
For instance, I was working on a heavily documented file, and realized I had accidentally deleted the Javadoc in one section of the file. I had done this a long time ago. I selected the lines where the Javadoc used to be, C-_, and boom, there it was, without affecting anything else in the document.
Wonderful stuff.
Labels: emacs, little emacs tricks
