With regard to indirect buffers mentioned in the accepted answer...
M-x clone-indirect-buffer
will create an indirect buffer for the current buffer. The name of the new buffer will have '<2>' added to it (or a greater number if you've already got duplicate buffer names). The new buffer is opened in a new window. You can switch back to a single window using C-x 0
or C-x 1
.
With M-x winner-mode
you can easily switch between the two locations. C-c <left>
/ M-x winner-undo
and C-c <right>
/ M-x winner-redo
switches between window configurations. In this case the configurations will be positions in the two buffers viewing the one file.
Note: the winner-undo
and winner-redo
functions work on a list of configurations. If the configuration is changed, e.g. moving point, then the current configuration becomes the head of the list and winner-redo
is invalid, in this case winner-undo
will bring back the previous position.
For the OP's situation this leads to the following process;
- Turn on winner mode
M-x winner-mode
- Visit file (filename: File1.txt, buffer name: File1.txt)
M-x clone-indirect-buffer
(new indirect buffer name: File1.txt<2>)- Make current window the only window
C-x 1
- Find first edit location, make changes.
- Switch to original buffer visiting file,
C-x b
(default will be original buffer unless a switch to another buffer took place since step 3). This creates a new configuration for winner to switch back to. - Find alternative edit location, make changes.
A switch to the previous edit location (windowrwindow configuration) depends on whether a change is made to the window configuration between switches;
- If a change is made switch using
C-c <left>
/M-x winner-undo
. - If no change is made switches useswitch using
C-c <left>
/M-x winner-undo
for back andC-c <right>
/M-x winner-redo
for forward.
A change is anything other than another winner-undo
or winner-redo
.