Книга: Learning GNU Emacs, 3rd Edition

4.6.5 Comparing Files Between Windows

4.6.5 Comparing Files Between Windows

Especially if you're looking for minute differences between large files, the compare-windows command comes in handy. To use compare-windows, you must first have the buffers you want to compare in two windows, either side by side or horizontally. Go to the beginning of each buffer, then type M-x compare-windows. Emacs scrolls each buffer to the place where the discrepancy is. It places the point in each buffer at the place of the discrepancy, so using C-x o to move the cursor between buffers will show you exactly where the files differ.[24]

Of course, this maneuver finds only the first difference between the two buffers. Finding the second, third, and so on, is a bit tricky. The compare-windows command works only if the point in both buffers is in exactly the same place. Therefore, you need to move past the discrepancy in both buffers before you can type M-x compare-windows again. The Unix diff command provides a more comprehensive (although somewhat awkward looking) way to find the differences between two files. Emacs also provides an interface to Ediff, with options on the Compare menu (a submenu of the Tools menu). Ediff is far more comprehensive; see Chapter 12 for details.

Table 4-4 summarizes the window commands discussed in this chapter.

Table 4-4. Window commands

Keystrokes Command name Action
C-x 2 File ? Split Window split-window-vertically Divide current window into two windows, one above the other.
C-x 3 split-window-horizontally Divide current window into two side-by-side windows.
C-x > scroll-right Scroll the window right.
C-x < scroll-left Scroll the window left.
C-x o other-window Move to the other window; if there are several, move to the next window (see "Navigating Windows").
C-x 0 delete-window Delete the current window.
C-x 1 File ? Unsplit Windows delete-other-windows Delete all windows but this one.
(none) delete-windows-on Delete all windows on a given buffer.
C-x ^ enlarge-window Make window taller.
(none) shrink-window Make window shorter.
C-x } enlarge-window-horizontally Make window wider.
C-x { shrink-window-horizontally Make window narrower.
C-x - shrink-window-if-larger-than-buffer Make window smaller if buffer is smaller than window.
C-x + balance-windows Make windows the same size.
C-M-v scroll-other-window Scroll other window.
C-x 4 f find-file-other-window Find a file in the other window.
C-x 4 b switch-to-buffer-other-window Select a buffer in the other window.
(none)Tools ? Compare (Ediff) ? This Window and Next Window compare-windows Compare this window with the next window and show the first difference.

Оглавление книги


Генерация: 0.078. Запросов К БД/Cache: 0 / 0
поделиться
Вверх Вниз