Dired, the directory Editor

转载 2011年10月13日 22:16:53
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.
% 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).

      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
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.

[emacs]dired mode

一些常用的命令 内容都从网络上收集的,主要为了自己学习所用。
  • lidonghat
  • lidonghat
  • 2016年10月22日 12:10
  • 1366

emacs Dired 快速入门

关于dired,现在属于emacs内嵌的功能,理解方式就是cli的资源管理器 方便键盘操作,解放你的鼠标。 打开: M-x dired or C-x C-f 目录名 移动: ...
  • bigmarco
  • bigmarco
  • 2011年11月21日 17:05
  • 3842


1 特性 ~~~~~~~  * 过滤不需要的文件显示  * 在Dired buffer中猜测需要执行的shell命令  * virtual-Dired,根据非Dired Buffer的内容模拟Dire...
  • lujun9972
  • lujun9972
  • 2015年05月26日 07:33
  • 651

Emacs dired 模式

C-x d 调用dired模式C-x C-f 也可以打开dired模式 只是要输入文件夹名字 而不是文件名字C-x 4 d 在另一个窗口中打开dired模式C-x 5 d 在另一个框架中打开dired...
  • cxmanzhao
  • cxmanzhao
  • 2010年06月21日 23:18
  • 3783

emacs dired简单操作

按键 说明 具体操作 + 新建文件夹 会有提示 C copy文件或者文件夹 Cx会有提示 D 删除文件或者文件夹 Dx会有提示 R 重命名文件或者文件...
  • u011729865
  • u011729865
  • 2016年09月03日 11:55
  • 471

Emacs笔记3——使用dired mode

  原文与ChinaUnix,发表于2008-12-12    恩,看了前面的几个设置,应该对Emacs的插件安装使用有一些了解了。现在的问题是,我急着要用Emacs编辑文件么,那么,今天就记录一下基...
  • sealingdust
  • sealingdust
  • 2009年03月11日 22:33
  • 2096

Emacs Dired Mode 批量打开文件的方法

  • PfanAya
  • PfanAya
  • 2011年11月14日 11:25
  • 3264


方法一: 把下面一段代码存在一个记事本上,再选择另存为1.cmd,最后运行! regsvr32 /u /s igfxpph.dll reg delete HKEY_CLASSES_ROOT...
  • yiya1989
  • yiya1989
  • 2014年02月20日 20:59
  • 1289


扩展Editor的目的:提供一个统一的接口,来让策划调节prefab里相关脚本的数值,避免策划直接调整数值时不小心修改了prefab里其他组件的设置  思路:  1、创建1个EditorWin...
  • Steven_2017
  • Steven_2017
  • 2017年06月29日 16:24
  • 450


  • qq_26508409
  • qq_26508409
  • 2018年01月04日 14:48
  • 11
您举报文章:Dired, the directory Editor