Dired, the directory Editor

You can also view a list of files in a directory with C-x C-d (list-directory). Unlike Dired, this command does not allow you to operate on the listed files.

1. Entering Dired
To invoke Dired, type C-x d (dired). This reads a directory name using the minibuffer, and opens a Dired buffer listing the files in that directory.

You can also invoke Dired by going C-x C-f(find-file) a directory name.

The variable dired-listing-switches specify the options to give to ls for listing the directory; this string must contain '-l'.

To display the Dired buffer in another window rather than in the selected window, use C-x 4 d (dired-other-window) instead of C-x d. C-x 5 d (dired-other-frame) uses a separate frame to display the Dired buffer.

2. Navigation in the Dired buffers
All the usual Emacs cursor motion commands are available in Dired buffers.

For extra convenience, SPC and n in Dired are equivalent to C-n. p is equivalent to C-p. DEL (move up and unflag) is also often useful simply  for moving up. j (dired-goto-file) prompts for a file name using the minibuffer, and moves point to the line in the Dired buffer describing that file. M-s f C-s (dired-isearch-filename) performsa forward incremental search in the Dired buffer, looking for matchesonly amongst the file names and ignoring the rest of the next in thebuffer. M-s f M-C-s (dired-isearch-filename-regexp) does the same, using a regular expression search.

3. Deleting Files with Dired
d          Flag this file for deletion.(dired-flag-file-deletion)
         Remove deletion flag on this line. (dired-unmark)
DEL     Move point to previous line and remove the deletion flag on that line. (dired-unmark-backwark)
x          Delete the file that are flagged for deletion. (dired-do-flagged-delete)

Youcan delete empty directories just like other files, but normally Diredcannot delete directories that are nonempty. If the variable dired-recursive-deletes is non-nil, then Dired can delete nonempty directories including all their contents.

4. Flagging Many Files at once
The #, ~, ., % &, and % d commands flag many files for deletion, based on their file names:
#                               Flag all auto-save files(files whose names start andend with '#')for deletion.(dired-flag-auto-save-files)
~                                Flag all backup files(files whose names end with '~') for deletion.(dired-flag-backup-files)
.(Period)                  Flag excess numeric backup files for deletion. The oldest andnewest few backup files of any one file are exempt;
                                 the middle ones are flagged.(period, dired-clean-directory)
% &                          Flag for deletion all files with certain kinds of nameswhich suggest you could easily create those files again.
                                 (dired-flag-garbage-files)
% d regexp RET     Flag for deletion all files whose names match the regular expression regexp.(dired-flag-files-regexp)
                  
5. Visiting Files in Dired
Allof these commands apply to the current line's file; if that file isreally a directory, these commands invoke Dired on that subdirectory
(making a separate Dired buffer).

f
e  
RET
      Visit the file described on the current line, like typing C-x C-f and supplying that file name (dired-find-file).
         like f, but uses another window to display the file's buffer(dired-find-file-other-window). The Dired buffer remains visible
             in the first window. This is like using C-x 4 C-f to visit the file.
C-o       Visit the file described on the current line, and display the buffer in another window, but do not select that window
             (dired-display-file).
v          View the file described on the current line, using M-x view-file(dired-view-file). Viewing a file with view-file is like viewing it,
             but is slanted toward moving around in the file conveniently and does not allow changing the file.
^          Visit the parent directory of the current directory(dired-up-directory). This is equivalent to moving to the line for '..'and
             typing f there.
           
6. Shell Commands in Dired
The Dired command ! (dired-do-shell-command) reads a shell command string in the minibuffer and runs that shell command on one or more files. The command X is a synonym for !.

The command & (dired-do-async-shell-command)does the same, except that it runs the shell command asynchronously.You can also do this with !, by appending a '&' character to theend of the shell command.

7. Subdirectories in Dired
A Dired buffer displays just one directory in the normal case; but you can optionally include its subdirectories as well.

i               Insert the contents of a subdirectory later in the buffer.Ifthe subdirectory's contents are already present in the buffer,
                 the i command just moves to it.

               update the subdirectory's contents. (dired-do-redisplay)
C-u k        delete the subdirectory on the subdirectory header line.

8. Moving over subdirectories
C-M-n    Go to next subdirectory header line, regardless of level(dired-next-subdir)
C-M-p    Go to previous subdirectory header line, regardless of level (dired-prev-subdir).
C-M-u    Go up to the parent directory's header line(dired-tree-up).
C-M-d    Go down in the directory tree, to the first subdirectory's header line(dired-tree-down).
<             Move up to the previous directory-file line(dired-prev-dirline).
>             Move down to the next directory-file line (dired-prev-dirline).

9. Hiding subdirectories
      Hide or show the subdirectory that point is in, and move point tothe next subdirectory (dired-hide-subdir). This is a toggle.
          A numeric argument serves as a repeat count.
M-$   Hide all subdirectories in this Dired buffer, leaving only their headerlines (dired-hide-all). Or, if any subdirectory is currently hidden,
          make all subdirectories visible again.
       
10. Updating the Dired buffer
g      Update the entire contents of the Dired buffer(revert-buffer).
     Update the specified files (dired-do-redisplay). If you use l on asubdirectory header line, it updates the contents of the
        corresponding subdirectory.
k      Delete the specified file lines---not the files, just the lines (dired-do-kill-lines).
s      Toggle between alphabetical order and date/time order (dired-sort-toggle-edit).
C-u s switches RET
        Refresh the Dired buffer using switches as dired-listing-switches.

11. Viewing Image Thumbnails in Dired
Image-Diredis a facility for browsing image files. To enter Image-Dired, mark theimage files you want to look at in the Dired buffer, using m as usual.Then type C-t d (image-dired-display-thumbs).This creates and switches to a buffer containing image-dired, corresponding
to the marked files.

You can also enter Image-Dired directly by typing M-x image-dired.

Toview and the image in its original size, either provide a prefixargument (C-u) before pressing RET, or type C-RET(image-dired-thumbnail-display-external) to display the image in anexternal viewer. You must first configure image-dired-external-viewer.

You can delete images through Image-Dired also. Type d (image-dired-flag-thumb-original-file)to flag the image file for deletion in the Dired buffer. You can alsodelete the thumbnail image from the thumbnail buffer with C-d (image-dired-delete-char).

In the thumbnail buffer, type L to rotate the original image 90 degrees anti clockwise, and R to rotate it 90 degrees clockwise.

12. other Dired Features
The command + (dired-create-directory) reads a directory name, and creates the directory if it does not already exist.

13. Operating on Files
All of these commands let you specify the files to manipulate in these ways:

Ifyou give the command a numeric prefix argument n, it operates on thenext n files, starting with the current file. (If n is negative, the
command operates on the -n files preceding the current line.)

Otherwise, if some files are marked with '*', the command operates on all those files.

Otherwise, the command operates on the current file only.

All of these commands is omited. But you may refer to the  GNU Emacs Manual.

NOTE: This article comes from GNU Emacs Manual.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值