Êíèãà: Learning GNU Emacs, 3rd Edition

5.2.7 Navigating Directories

5.2.7 Navigating Directories

Often when you are cleaning up directories, you're moving files between them, organizing subdirectories, and the like. This naturally involves a lot of moving among directories.

To move to the parent directory of the one you're in, press ^. To move to the next directory in the buffer, press >; pressing <, not surprisingly, moves you to the previous directory in the buffer.

Sometimes it's more convenient to edit a directory and its subdirectories in the same buffer. To insert a subdirectory in the current Dired buffer, move to it and press i. Emacs inserts the subdirectory at the end of the buffer. If you insert more subdirectories in this fashion, they will appear in alphabetical order at the end of the buffer.

As you can see, much of your file maintenance and cleanup can be done easily from within Dired. Table 5-2 summarizes Dired commands, some of which we haven't fully discussed. There's more to learn about Dired,[29] but now that you know the basics, you can experiment on your own.

Table 5-2. Dired commands

Keystrokes Command name Action
C-x d File ? Open Directory dired Start Dired.
A Operate ? Search Files dired-do-search Do a regular expression search on marked files; stops at first match; M-, finds next match.
B Operate ? Byte-compile dired-do-byte-compile Byte-compile file.
C Operate ? Copy to dired-do-copy Copy file.
d Mark ? Flag dired-flag-file-deletion Flag for deletion.
D Operate ? Delete dired-do-delete Query for immediate deletion.
e Immediate ? Find This File dired-find-file Edit file.
f dired-advertised-find-file Find (so you can edit).
g Immediate ? Refresh revert-buffer Reread the directory from disk.
G Operate ? Change Group dired-do-chgrp Change group permissions.
h describe-mode Display descriptive help text for Dired.
H Operate ? Hardlink to ... dired-do-hardlink Create a hard link to this file; Emacs asks you to name the hard link (not all OSes support hard links).
i Subdir ? Insert This Subdir ... dired-maybe-insert-subdir Add a listing of this subdirectory to the current dired buffer; if it's already there, just move to it.
k dired-do-kill-lines Remove line from display (don't delete file).
L Operate ? Load dired-do-load Load file.
m or * m Mark ? Mark dired-mark Mark with *.
M Operate ? Change Mode dired-do-chmod Use chmod command on this file.
n dired-next-line Move to next line.
o Immediate ? Find in Other Window dired-find-file-other-window Find file in another window; move there.
C-o Immediate ? Display in Other Window dired-display-file Find file in another window; don't move there.
O Operate ? Change Owner dired-do-chown Change ownership of file.
p dired-previous-line Move up a line.
P Operate ? Print dired-do-print Print file.
q quit-window Quit Dired.
Q Operate ? Query Replace in Files dired-do-query-replace Query replace string in marked files.
R Operate ? Rename to dired-do-rename Rename file.
S Operate ? Symlink to dired-do-symlink Create a symbolic link to this file; Emacs asks you to name the symbolic link.
s dired-sort-toggle-or-edit Sort the Dired display by date or by filename (toggles between these).
t Mark ? Toggle Marks dired-toggle-marks Toggle marks on files and directories; pressing t once marks all unmarked files and directories; pressing t again restores original marks.
u Mark ? Unmark dired-unmark Remove mark.
v Immediate ? View This File dired-view-file View file (read-only).
w dired-copy-filename-as-kill Copy filename into the kill ring; if multiple files are marked, copy names of all marked files to kill ring.
x dired-do-flagged-delete Delete files flagged with D.
y dired-show-file-type Display information on the type of the file using the file command.
Z Operate ? Compress dired-do-compress Compress or uncompress file.
~ Mark ? Flag Backup Files dired-flag-backup-files Flag backup files for deletion; C-u ~ removes flags.
# Mark ? Flag Auto-save Files dired-flag-auto-save-files Flag auto-save files for deletion; C-u # removes flags.
& Mark ? Flag Garbage Files dired-flag-garbage-files Flag "garbage" files for deletion.
.Mark ? Mark Old Backups dired-clean-directory Flag numbered backups for deletion (if any).
= Immediate ? Diff dired-diff Compare this file to another file (the one at the mark).
M-= Immediate ? Compare With Backup dired-backup-diff Compare this file with its backup file.
! or X Operate ? Shell Command dired-do-shell-command Ask for shell command to execute on the current file or marked files.
+ Immediate ? Create Directory dired-create-directory Create a directory.
> Subdir ? Next Dirline dired-next-dirline Move to next directory.
< Subdir ? Prev Dirline dired-prev-dirline Move to previous directory.
^ dired-up-directory Find the parent directory in a new Dired buffer.
$ Subdir ? Hide/Unhide Subdir dired-hide-subdir Hide or show the current directory or subdirectory.
M-$ Subdir ? Hide All dired-hide-all Hide all subdirectories, leaving only their names; repeat command to show.
C-M-n Subdir ? Next Subdir dired-next-subdir Move to next subdirectory (if you've inserted subdirectories using i).
C-M-p Subdir ? Prev Subdir dired-prev-subdir Move to previous subdirectory (if you've inserted subdirectories using i).
C-M-u Subdir ? Tree Up dired-tree-up If you've inserted subdirectories using i, move to the parent directory in this buffer.
C-M-d Subdir ? Tree Down dired-tree-down If you've inserted subdirectories using i, move to the first subdirectory for this directory in this buffer.
* c Mark ? Change Marks dired-change-marks Change marks on specified files, for example, from * (generic mark) to D (flagged for deletion).
* ! or M-Del Mark ? Unmark All dired-unmark-all-files Remove all marks from all files.
* * Mark ? Mark Executables dired-mark-executables Mark executables; C-u * unmarks.
* / Mark ? Mark Directories dired-mark-directories Mark directories; C-u / unmarks.
* @ Mark ? Mark Symlinks dired-mark-symlinks Mark symlinks; C-u * @ unmarks.
M-} Mark ? Next Marked dired-next-marked-file Move to the next file marked with * or D.
M-{ Mark ? Previous Marked dired-prev-marked-file Move to previous file marked with * or D.
% d Regexp ? Flag dired-flag-files-regexp Flag for deletion files that match regular expression.
% g Regexp ? Mark Containing dired-mark-files-containing-regexp Mark files whose contents match regular expression.
% l Regexp ? Downcase dired-downcase Lowercase marked files.
% R Regexp ? Mark dired-do-rename-regexp Rename files with filenames that match regular expression.
% u Regexp ? Upcase dired-upcase Uppercase marked files.

Îãëàâëåíèå êíèãè


Ãåíåðàöèÿ: 1.558. Çàïðîñîâ Ê ÁÄ/Cache: 3 / 0
ïîäåëèòüñÿ
Ââåðõ Âíèç