Shell Buffer
Running one command at a Time
In Emacs session -> M-! -> prompt "shell command" -> cat /home/ryu/test -> display in *Shell Command Output*
C-u M-! 与 M-!不同的是,它直接显示结果在当前buffer中鼠标所在位置后面
region Command
有一些命令跟我们在终端时候的情形不太一样,比方说我们可以对一个region使用Command命令。
M-h 命令mark-paragraph ->M-| -> prompt " shell command on region" -> type 'sort RET'
Using Shell Mode
M-x shell RET create *shell* buffer
Emacs 实际上就相当于一个shell的命令接口,只是现在我们可以对这些进行直接的复制,修改等操作。但是他们还是有些不同的操作要注意。我们在terminal中可以执行C-c来终止一个命令
M-p bring back earlier commands 在mini-buffer中会显示History item
Enter 在shell-mode中它会执行光标所在行的命令,同时你可以先修改这个命令然后再确认;这个相当与重复执行以前命令。
Tab 进行自动补全,其中包括文件名,系统命令等,Emacs跟windows 有的时候不是太顺畅。
C-c C-o 自动删除上一个命令的输出comint-kill-output 命令
C-c C-r comint-show-output 如果命令的输出太长,造成最前面的输出出界。你可以通过这个命令把光标移动到最开始输出的位置
C-c C-e comint-show-maximum-output 来查看命令的最底部输出
Multipul shell buffer
M-x rename-uniquelyrename current buffer, then you can typeM-x shellto create another shell buffer.
Using Dired
Dired is one of the most interesting features of Emacs. For example, you can work with groups of files, deleting, moving, compressing, or even query-replacing strings in them.
编辑目录方式
1:C-x C-f 我们一般都是指定一个文件名,现在你只需指定一个文件夹名就行了。
2:C-x d
当显示的时候他会支持颜色设置,如果你发现它都是一样颜色的话,可以输入命令M-x font-lock-mode,或者直接在.emacs中加入(global-font-lock-mode t)
你会发现显示的方式是按字母排序(Dired by name)这个时候你可以通过输入s(for dired-sort-toggle-or-edit)将它们按日期排序。
因为它显示的形式就好像ls -al 命令得到的形式差不多,然后类比我们处理buffer-list时候的各种快捷键,同样在这里适用。
v dired-view-file Emacs display the file in view mode,q to return to directory listing. 当你在视图模式的时候可以输入s进行incremental search.输入enter的话会一行一行的向下滚动。
f find
e edit
d delete file you can mark as many files as you want
u unmark flag
x execute
# delete file's auto-save file,end up with #
C capital C, 会提示你输入目的文件,3C会复制当前文件及下面2个文件
R rename
Compressing and Uncompressing files
Z dired-do-compress Emacs ask "compress or uncompress",Emacs只会压缩成gzip格式.gz,但是如果你解压缩的时候他也能够正确认识.z .Z or .gz,
M-x auto-compress-mode RET 可以使Emacs编辑压缩文件
Comparing Files
=
M-= 比较文件和备份文件以~结尾,直接在备份文件行输入该命令就会转到*diff* buffer
Running shell command on files
首先输入一个感叹号!然后你就可以对file进行各种文件操作命令sort, grep, find, chmode
! Prompt "! on filename: "
* asterisks 意思时用光标所在位置文件或我所标记的。
? question mark如果很多个文件都被标记了,它会让每个文件都分开执行该命令
比如"! on file: sort * > file-out" 他就是把标记或者所在位置的文件经过排序以后输出到file-out.
Mark
m mark file with an asterisk,Emacs assumes that you want to operate on these files. 3m mark the file and the next two files.
Delete mark
M-Del 你会发现即使把所要处理的文件都处理了,标记仍存在,这个时候你可以用命令dired-unmark-all-files来移除标记 del是键delete
Invert mark
t toggles the marks, 标记为标记的,取消已经标记的
select files
# #filename# auto-saved files created when a session terminates abnormally
~ filename~ backup file which Emacs creates periodically
** select executable files
*/ select directories
*@ select symbolic links
Using regular expression to choose files
%m ^c mark all the file start with c
%g 用与标记,谁的内容符合某一条件
在这里它跟grep中正则表达式一样,find/ls命令都会把^当成一个普通字符
Operating on group of files
+ dired-create-directory 创建subdirectories.
R like mv command in unix. renaming file and moving file.当发现文件都已经标记了以后,他就会移动这些文件,而不是改名字。
searching in group of files
A dired-do-search do a regular expression on marked files,stop at first match, M- finds next match.
Q dired-do-query-replace 他会顺序查询搜索search string.注意如果你用recursive edit中止的话,你必须再回到Dired buffer 才能够开始