Emacs on windows
目录
- Installation and configuration
- Installing Emacs and setting up .emacs
- Backup files
- Recycle Bin
- Integration with the Windows File Explorer
- Getting rid of the start-up screen and toolbar
- Changing fonts
- Enabling commands to change case
- Spell check
- Installing color-theme
- Installing nXhtml
- Installing powershell-mode
- Remapping my keyboard
- Line wrapping
- Column position
- Emacs vocabulary
- Emacs的词汇
- Editing LaTeX
- Editing source code
- Selecting and deleting text
- Searching and replacing
- *正则表达式
- *代替
- Saving text and positions
- *保存文本
- *保存位置
- The Emacs help system
- Emacs帮助系统
- Navigating files, buffers, and windows
- *文件
- *缓冲
- *的窗户
- Miscellaneous commands
- Emacs resources
- Emacs资源
These notes summarize some of my discoveries (re-)learning GNU Emacs. Since these are my personal notes, it may help to briefly describe my background. I used Emacs on Unix from somewhere around 1990 until 1995. Then in 1995 I began using Windows as my primary operating system and stopped using Emacs. In 2010 I decided to give Emacs on Windows another try. I may not mention some basic things just because I remember them from my initial experience. 这些笔记总结了我在学习GNU Emacs时的一些发现。由于这些是我的个人笔记,简要介绍一下我的背景可能会有所帮助。从1990年到1995年,我一直在Unix上使用Emacs。然后在1995年,我开始使用Windows作为我的主要操作系统,并停止使用Emacs。2010年,我决定在Windows上再试一次Emacs。我可能不会提到一些基本的事情,因为我从我最初的经验中记得它们。
These notes are not a thorough introduction to Emacs. For a more systematic reference, the Emacs Wiki is a good place to start. I wanted to write these things down for future reference, and I put this file up on my web site in case someone else finds it useful. If you have comments or corrections, please let me know. 这些笔记并不是对Emacs的全面介绍。要获得更系统的参考资料,可以从Emacs Wiki开始。我想把这些东西写下来,以备将来参考,我把这个文件放在我的网站上,以防别人发现它有用。如果您有任何意见或更正,请让我知道。
Installation and configuration
*安装和配置
属性: :CUSTOM_ID: install :CUSTOM_ID:安装
结束:
Installing Emacs and setting up .emacs
*安装Emacs并设置.emacs
属性: :CUSTOM_ID: dotemacs :CUSTOM_ID dotemacs
结束:
I install all my Unix-like software under C:bin
and have that directory in my Windows PATH
environment variable. I installed Emacs 23.1 in C:binemacs-23.1
and created an environment variable HOME
set to C:bin
. The significance of HOME
is that Emacs can find your configuration file if you put it there. This file is called “dot emacs” because the traditional name for the file on Unix systems is .emacs
. On Windows, it is more convenient to name the file _emacs
. (You can also name the file _emacs.el
. Giving the file the .el
extension causes Emacs to open the file in Lisp mode. And if someday the file becomes huge, you can compile it to make startup faster.)
我在=C:bin=下安装了所有的类unix软件,并在我的Windows PATH=环境变量中安装了那个目录。我在=C:binemacs-23.1=中安装了Emacs 23.1,并创建了一个环境变量=HOME
set to C:bin=。=HOME=的意义在于,如果您将配置文件放在这里,Emacs可以找到它。这个文件被称为“。emacs”,因为Unix系统上文件的传统名称是
.emacs=。在Windows上,将文件命名为=_emacs=更方便。(也可以将文件命名为=_emacs.el=。给文件一个=。el=扩展导致Emacs以Lisp模式打开文件。如果有一天文件变大了,你可以编译它来加快启动速度。
Backup files
*备份文件
属性: :CUSTOM_ID: backup :CUSTOM_ID:备份
结束:
Emacs automatically saves backup versions of file and by default leaves these backup files beside the files being edited. This can be annoying. Some people call these extra files “Emacs droppings.” Adding the following lines to .emacs
instructs Emacs to put all backup files in a temporary folder.
Emacs自动保存文件的备份版本,默认情况下将这些备份文件放在正在编辑的文件旁边。这可能很烦人。有些人把这些额外的文件称为“Emacs的粪便”。向=添加以下行。emacs=指示emacs将所有备份文件放在临时文件夹中。
(setq backup-directory-alist `((".*" . ,temporary-file-directory))) (setq auto-save-file-name-transforms `((".*" ,temporary-file-directory t)))
Recycle Bin
(咒语)
属性: :CUSTOM_ID: recycle :CUSTOM_ID:回收
结束:
The following line configures Emacs so that files deleted via Emacs are moved to the Recycle. 下面的行配置Emacs,以便通过Emacs删除的文件被移动到回收。
(setq delete-by-moving-to-trash t)
More details here. 更多的细节([http://www.masteringemacs.org/articles/2010/12/30/making-deleted-files-trash-can/][这]]。
Integration with the Windows File Explorer
*与Windows文件资源管理器的集成
属性: :CUSTOM_ID: explorer :CUSTOM_ID:资源管理器
结束:
The following registry script creates an “Open with Emacs” option in the Windows file explorer context menu. 下面的注册表脚本在Windows文件管理器上下文菜单中创建一个“用Emacs打开”选项。
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT*ShellOpen In EmacsCommand] @=""C:\bin\Emacs-23.1\bin\emacsclientw.exe" -a "C:\bin\Emacs-23.1\bin\runemacs.exe" "%1""
See also this blog post for how to open a file in a running instance of Emacs rather than starting a new instance for each file.Putting these two lines in .emacs
creates a menu item File -> Open recent.
参见这个博客文章,了解如何在Emacs的运行实例中打开文件,而不是为每个文件启动一个新的实例。把这两行代入=。创建一个菜单项文件->打开最近。
(require 'recentf) (recentf-mode 1)
If you have a desktop shortcut to runemacs
, you can open a file in Emacs by dropping it on the shortcut icon.
如果您有=runemacs=的桌面快捷方式,您可以通过将文件放到快捷方式图标上来打开Emacs中的文件。
Getting rid of the start-up screen and toolbar
*去掉启动界面和工具栏
属性: :CUSTOM_ID: startup :CUSTOM_ID:启动
结束:
I turned off initial start-up screen by adding (setq inhibit-startup-screen t)
to .emacs
. This had the pleasant side effect of making the “Open with Emacs” context menu work as expected. (Before, Emacs would open with a split window. Now it opens with just the “sent” file.)
我通过添加=(setq -startup-screen t)= to =.emacs=来关闭初始启动屏幕。这带来了一个令人愉快的副作用,使“使用Emacs打开”上下文菜单按预期工作。(在此之前,Emacs将使用拆分窗口打开。现在它只打开“发送”的文件。)
Got rid of the toolbar by using the configuration editor under Options / Customize Emacs. 通过使用选项/自定义Emacs下的配置编辑器摆脱工具栏。
Changing fonts
*改变字体
属性: :CUSTOM_ID: fonts :CUSTOM_ID:字体
结束:
I used the Options menu to change the default font to Consolas. 我使用选项菜单将默认字体更改为Consolas。
Enabling commands to change case
*允许命令改变大小写
属性: :CUSTOM_ID: case :CUSTOM_ID:案例
结束:
The commands for converting the text in a region to upper or lower case are disabled by default. (The GNU Emacs manual says beginners find these commands confusing and so you have turn them on. That seems very strange. Many other Emacs commands are more confusing.) The following turns the commands on. 默认情况下,将区域中的文本转换为大写或小写的命令是禁用的。(GNU Emacs手册上说初学者会觉得这些命令令人困惑,所以你必须打开它们。这似乎很奇怪。其他许多Emacs命令更令人困惑。)下面打开命令。
(put 'upcase-region 'disabled nil) (put 'downcase-region 'disabled nil)
Once this is enabled, you can make the text in a region lowercase with C-x C-l
or uppercase with C-x C-u
.
一旦这是启用,您可以使文本在一个地区小写=C-x C-l=或大写=C-x C-u=。
Spell check
*拼写检查
属性: :CUSTOM_ID: aspell :CUSTOM_ID aspell
结束:
GNU Emacs does not provide a spell checker. Instead, it provides hooks to install your own spell checker, usually Aspell. I downloaded Aspell version 0.50.3 (win32) from here. I then installed the English dictionary from the same page. The dictionary installer warned me that Aspell was already installed and suggested that I uninstall it. I did, thinking that it might install a newer version. That didn' work. I re-installed Aspell, then installed the dictionary, ignoring the warning. Everything worked fine. GNU Emacs不提供拼写检查程序。相反,它提供了钩子来安装您自己的拼写检查程序,通常是Aspell。我从此处下载了Aspell版本0.50.3 (win32)。然后我从同一页安装了英语词典。字典安装程序警告我Aspell已经安装,并建议我卸载它。我照做了,以为它可能会安装一个更新的版本。,的工作。我重新安装了Aspell,然后安装了字典,忽略了警告。一切都工作好。
After installing Aspell, I let Emacs know where to find it by adding these lines to my .emacs
file.
安装了Aspell之后,我将这些行添加到my =中,让Emacs知道在哪里可以找到它。emacs =文件。
(setq-default ispell-program-name "C:/bin/Aspell/bin/aspell.exe") (setq text-mode-hook '(lambda() (flyspell-mode t) ))
The command M-x ispell
will run the spell checker on your file. If flyspell-mode
is turned on, as it is in the lines above, misspelled words are underlined in red as you type.
命令=M-x ispell=将在您的文件上运行拼写检查程序。如果=flyspell-mode=被打开,就像在上面的行中一样,拼写错误的单词在您键入时用红色下划线标出。
Installing color-theme
*安装颜色主题
属性: :CUSTOM_ID: color :CUSTOM_ID:颜色
结束:
It was difficult to find a more direct way to configure the color schemes that Emacs uses, so I installed color-theme
version 6.60. I then used color theme creator to create a basic theme then tweaked the colors.
很难找到更直接的方法来配置Emacs使用的配色方案,因此我安装了=color-theme= version 6.60。然后我使用颜色主题创建器创建一个基本的主题,然后调整颜色。
Installing nXhtml
*安装nXhtml
属性: :CUSTOM_ID: nxhtml :CUSTOM_ID nxhtml
结束:
The default support for editing HTML files was less than I expected. I heard good things about nXhtml and decided to go with it. Notice that it inserts extra menus when you open a file in nXhtml mode. You can use the commands from the menu until you learn their keyboard shortcuts. 编辑HTML文件的默认支持比我预期的少。我听到了关于nXhtml的好消息,并决定使用它。注意,当您以nXhtml模式打开文件时,它会插入额外的菜单。您可以使用菜单中的命令,直到您了解它们的键盘快捷键。
nXhtml mode requires HTML to be valid XHTML. If your HTML is not valid, you can use HTML Tidy to bring it into standard compliance. HTML Tidy appears as a menu option under nXhtml, but it must be installed separately. Installing HTML Tidy is very simple: download two files, the executable and a DLL, and copy them to somewhere in your path. Once HTML Tidy is installed, it will continually check the validity of the XHTML. It will display its status in the mode line and will turn angle brackets red that are not in the correct place. nXhtml模式要求HTML是有效的XHTML。如果您的HTML无效,您可以使用HTML Tidy使其符合标准。HTML Tidy作为菜单选项出现在nXhtml下,但必须单独安装。安装HTML Tidy非常简单:下载两个文件,可执行文件和一个DLL,然后将它们复制到路径中的某个地方。一旦安装了HTML Tidy,它将不断地检查XHTML的有效性。它将在模式行中显示它的状态,并将尖括号变为红色,因为它不在正确的位置。
Incidentally, the table of contents for this page was automatically generated using nXhtml. Just give every <h>
tag an id. Then you can use commands from the nXhtml menu to insert the table of contents and its style sheet.
顺便说一下,这个页面的目录是使用nXhtml自动生成的。只需给每个=<h>=标签一个id,然后你就可以使用nXhtml菜单中的命令来插入目录及其样式表。
NB: Apparently the nXhtml code does not allow a space on either side of the equal sign when specifying the id
value.
注意:在指定=id=值时,nXhtml代码显然不允许等号两边有空格。
Installing powershell-mode
*安装powershell-mode
属性: :CUSTOM_ID: powershell :CUSTOM_ID powershell
结束:
I installed a mode for editing PowerShell code by copying powershell-mode.el
, downloaded from here, by copying the file to C:binemacs-23.1site-lisp
, which is in my Emacs load-path
. I tried installing some code that would allow me to run PowerShell as a shell inside Emacs. That did not work on the first try and I did not pursue it further.
我安装了一个通过复制= PowerShell模式编辑PowerShell代码的模式。,从此处下载,将文件复制到=C:binemacs-23.1site-lisp=,它在我的Emacs =load-path=中。我尝试安装一些代码,这些代码允许我在Emacs中以shell的形式运行PowerShell。第一次尝试没有成功,我也没有继续下去。
Remapping my keyboard
重新映射我的键盘
属性: :CUSTOM_ID: keyboard :CUSTOM_ID:键盘
结束:
Many Emacs users recommend remapping your keyboard so that the caps lock key becomes a control key. I don't like the idea of changing my keyboard just to accommodate one program, even a program I may use very often. However, I recently bought a laptop that came with a Fn key right where my muscle memory expects the left control key. I hardly ever use the caps lock key, so I made it a control key for the sake of Emacs and for making it easier to use my laptop. I mapped the scroll lock key, a key I have not used in a decade or two, to caps lock in case I ever need a caps lock key. My initial intention was to keep the original left control key as an addition control key, but then I disabled it to force myself to get into the habit of using my new control key. I mapped the keyboard of every computer I use to be the same. This has been hard to get used to. 许多Emacs用户建议重新映射键盘,使大写锁定键成为控制键。我不喜欢仅仅为了适应一个程序而改变我的键盘,即使是一个我经常使用的程序。不过,我最近买了一台笔记本电脑,它的Fn键正好在我的肌肉记忆所期待的左侧控制键的位置。我很少使用大写锁定键,所以为了方便Emacs和使用我的笔记本电脑,我把它做成了一个控制键。我把滚动锁定键(这把键我已经有一二十年没用过了)映射成大写锁定键,以备需要大写锁定键时使用。我最初的意图是保留原来的左控制键作为附加控制键,但后来我禁用了它,迫使自己养成使用新控制键的习惯。我把我用过的每台电脑的键盘都映射成相同的形状。这很难适应。
I used the KeyTweak application to remap my keyboards. 我使用KeyTweak应用程序来重新映射我的键盘。
I don't know what I want to do for my “Meta” key. For now I'm using the Esc key. Some recommend using the original Control key after remapping the Caps Lock key. I have two problems with that: it will not work on my laptop, and I first have to break my habit of using the original Control key as a Control key. (Why not just remap the Fn key on my laptop? Unfortunately this key cannot be remapped like an ordinary key.) I may try to get in the habit of using the right Alt key as my Meta key. 我不知道我想做什么为我的“元”键。现在我使用的是Esc键。有些人建议在重新映射大写锁定键之后使用原始的控制键。我有两个问题:它不能在我的笔记本电脑上工作,我首先必须打破使用原来的控制键作为控制键的习惯。(为什么不在我的笔记本电脑上重新映射Fn键呢?不幸的是,这个密钥不能像普通密钥那样重新映射。)我可能会尝试养成使用正确的Alt键作为我的元键的习惯。
Line wrapping
*线包装
属性: :CUSTOM_ID: linewrap :CUSTOM_ID linewrap
结束:
I set global-visual-line-mode
as the default way to handle line wrap. I did this through the menu sequence Options / Customize Emacs / Specific Option. This causes text to flow as it does in most Windows programs.
我将=global- visualline -mode=设置为处理换行的默认方式。我是通过菜单序列选项/自定义Emacs /特定选项来实现的。这将导致文本像在大多数Windows程序中一样流动。
Column position
*列的位置
属性: :CUSTOM_ID: Column :CUSTOM_ID:列
结束:
By default, Emacs displays the current line number in the mode line but not the current column number. To display the column number, add the following to your .emacs
file.
默认情况下,Emacs在模式行中显示当前行号,而不是当前列号。要显示列号,请将以下内容添加到您的=中。emacs =文件。
(setq column-number-mode t)
Emacs vocabulary
Emacs的词汇
属性: :CUSTOM_ID: vocabular :CUSTOM_ID:词汇的
结束:
Emacs uses a set of terminology that is not commonly used elsewhere. The following correspondences are not exact, but they are a good first approximation. Emacs使用了一组在其他地方不常用的术语。下面的对应关系并不精确,但它们是一个很好的初步近似值。
*Emacs terminologyCommon terminology*fillword wrapyankpastekillcutkill ringclipboardmode linestatus barpointcursorfont locksyntax coloring *Emacs术语常用术语*fillword wrapyankpastekillcutkill ringclipboardmode linestatus barpointcursorfont locksyntax着色
The “echo area” is the very bottom of an Emacs window. It echoes commands, displays the minibuffer, and provides a place to type extra arguments for commands. “echo区域”是Emacs窗口的最底部。它回显命令,显示minibuffer,并提供一个位置来为命令输入额外的参数。
Editing LaTeX
*编辑乳胶
属性: :CUSTOM_ID: latex :CUSTOM_ID:乳胶
结束:
One of the most useful key sequences for editing LaTeX files are C-c C-o
to insert a begin
and end
pair. Emacs will prompt you for the keyword to put inside the begin{}
statement. Another useful key sequence is C-c C-f
to run latex
on a file. (Emacs can detect whether a file is plain TeX or LaTeX. I use LaTeX exclusively.)
编辑LaTeX文件最有用的键序列之一是=C-c C-o=插入一个=begin=和=end=对。Emacs将提示您在=begin{}=语句中输入关键字。另一个有用的键序列是=C-c C-f= to run latex
on a file。(Emacs可以检测一个文件是纯TeX还是LaTeX。我只使用乳胶。)
There is Emacs package AUCTex for editing (La)TeX files, but I have not tried it. 有Emacs包AUCTex用于编辑(La)TeX文件,但我没有尝试过。
I would like to have C-c C-f
run pdflatex
rather than latex
, but I have not found out how to configure that.
我想要=C-c C-f= run =pdflatex=而不是=latex=,但我还没有找到如何配置它。
Editing source code
*编辑源代码
属性: :CUSTOM_ID: programs :CUSTOM_ID:项目
结束:
Here are a few useful commands for editing source code files. 下面是一些用于编辑源代码文件的有用命令。
*CommandExplanation*C-M-aGo to beginning of a function definitionC-M-eGo to end of a function definitionC-M-hPut a region around a function definitionC-jInsert a newline and properly indent the next line 把一个区域放在一个函数定义的周围,然后正确地缩进下一行
I put these lines in my .emacs
file to make the C++ mode behave more like what I am accustomed to.
我把这些线代入=。emacs=文件,使c++模式的行为更像我所习惯的。
(add-hook 'c++-mode-hook '(lambda () (c-set-style "stroustrup") (setq indent-tabs-mode nil)))
Selecting and deleting text
*选择和删除文本
属性: :CUSTOM_ID: select :CUSTOM_ID:选择
结束:
C-x h
selects the entire current buffer.
=C-x h=选择整个当前缓冲区。
You select a region by using C-SPACE
at one end of the region and a selection command and moving the point (cursor) to the other end of the region. Then you can use C-w
to cut or M-y
to copy. The paste command is C-y
. Emacs maintains a “kill ring”, something analogous to the Windows clipboard but containing more than just the latest cut or copy. For example, C-y M-y.
lets you paste the next-to-last thing that was cut. Use M-y
again to paste the cut before that, etc.
在区域的一端使用=C-SPACE=和选择命令选择一个区域,然后将点(光标)移动到区域的另一端。然后你可以使用=C-w=剪切或=M-y=复制。粘贴命令是=C-y=。Emacs维护一个“杀死环”,类似于Windows剪贴板,但包含的不仅仅是最新的剪切或复制。例如,=C-y - M-y。=让你粘贴倒数第二个被剪切的东西。再次使用=M-y=粘贴之前的剪切,等等。
You can kill all but one whitespace character with M-SPACE
. You can kill all but one blank line with C-x C-o
.
您可以使用=M-SPACE=杀死除一个空白字符外的所有空白字符。使用=C-x C-o=可以杀死除一行之外的所有空行。
Emacs has commands for working with rectangular regions, analogous to vertical selection in some Windows programs. Specify a rectangular region by setting the mark at one corner and the point at the opposite corner. All commands for working with rectangular regions start with C-x r
. Here are a few rectangular region commands.
Emacs有处理矩形区域的命令,类似于某些Windows程序中的垂直选择。通过在一个角上设置标记和在另一个角上设置点来指定一个矩形区域。处理矩形区域的所有命令都以=C-x r=开始。下面是一些矩形区域命令。
*CommandExplanation*=C-x r k=Kill the rectangle=C-x r d=Delete the rectangle=C-x r c=Clear the rectangle, i.e. fill the region with whitespace=C-x r y=Yank (paste) the rectangular region 命令解释*= c -x r k=删除矩形= c -x r d=删除矩形= c -x r c=清除矩形,即填充空白区域= c -x r y=拉(粘贴)矩形区域
Searching and replacing
*搜寻及更换
属性: :CUSTOM_ID: searchandreplace :CUSTOM_ID searchandreplace
结束:
Searching for strings
搜索字符串
属性: :CUSTOM_ID: search :CUSTOM_ID:搜索
结束:
Use C-s
for forward incremental search, C-r
for backward incremental search. Type another C-s
or C-r
to repeat the search. Type RET to exit search mode.
使用=C-s=用于前向增量搜索,=C-r=用于后向增量搜索。键入另一个=C-s=或=C-r=来重复搜索。键入RET退出搜索模式。
Regular expressions
*正则表达式
属性: :CUSTOM_ID: regex :CUSTOM_ID:正则表达式
结束:
C-M-s
and C-M-=r are the regular expression counterparts of =C-s
and C-r
.
=C-M-s=和=C-M-=r是=C-s=和=C-r=的正则表达式。
Emacs regular expressions must escape the vertical bar | and parentheses. For example, the Perl regular expression (a|b)
becomes (a|b)
in Emacs.
Emacs正则表达式必须转义竖线|和括号。例如,在Emacs中,Perl正则表达式=(a|b)=变成了=(a|b)=。
Emacs regular expressions do not support lookaround. Emacs正则表达式不支持查找。
The whitespace patterns s
and S
in Perl are written as s-
and S-
in Emacs. There is no equivalent of Perl's d
except to use the range [0-9]
.
在Emacs中,Perl中的空白模式=s=和=s=被写成=s-=和=s-=。除了使用range =[0-9]=外,没有与Perl的=d=等价的东西。
Replacing
*代替
属性: :CUSTOM_ID: replace :CUSTOM_ID:替换
结束:
Use M-x replace-string
and M-x replace-regex
for replacing text. There are also interactive counterparts M-x query-replace
and M-x query-replace-regex
.
使用=M-x替换-string=和=M-x替换-regex=替换文本。还存在交互对等项=M-x query-replace=和=M-x query-replace-regex=。
Saving text and positions
*保存文本和位置
属性: :CUSTOM_ID: saving :CUSTOM_ID:储蓄
结束:
Saving text
*保存文本
属性: :CUSTOM_ID: savingtext :CUSTOM_ID savingtext
结束:
You can save a region of text to a named register for later pasting. Register names can be any single character. The command to save to a register a is C-x r s a
. The command to insert the contents of register a is C-x r i a
.
您可以将文本的某个区域保存到指定的寄存器,以便以后进行粘贴。寄存器名可以是任何单个字符。保存到寄存器a的命令是=C-x r sa =。插入寄存器a内容的命令是=C-x r i a=。
Saving positions
*保存位置
属性: :CUSTOM_ID: bookmarks :CUSTOM_ID:书签
结束:
Bookmarks are named positions in a buffer. The command to create a bookmark is C-x r m bookmark_name
. The command to go to a bookmark is C-x r b bookmark_name
.
书签被命名为缓冲区中的位置。创建书签的命令是=C-x r m bookmark_name=。转到书签的命令是=C-x r b bookmark_name=。
The Emacs help system
Emacs帮助系统
属性: :CUSTOM_ID: help :CUSTOM_ID:帮助
结束:
All help commands start with C-h
. If you don't know a more specific location to go to, you can start by typing C-h C-h
to get to the top of a navigation system for help.
所有帮助命令都以=C-h=开头。如果你不知道更具体的地点,你可以输入=C-h C-h=进入导航系统的顶部寻求帮助。
C-h m
is very useful. It displays all active modes and describes key bindings.
=C-h m=非常有用。它显示所有活动模式并描述键绑定。
C-h k
tells what command is bound to a key and gives documentation on how it is used. C-h w
is a sort of opposite: given a command, it sells what keys are bound to that command.
=C-h k=告诉什么命令绑定到一个键,并提供文档说明如何使用它。=C-h w=是一种反义词:给定一个命令,它出售绑定到该命令的密钥。
Navigating files, buffers, and windows
*浏览文件、缓冲区和窗口
属性: :CUSTOM_ID: navigation :CUSTOM_ID:导航
结束:
Files
*文件
属性: :CUSTOM_ID: files :CUSTOM_ID:文件
结束:
The command to open a file is C-x C-f
. The command for ‘save as” is C-x C-w
.
打开文件的命令是=C-x C-f=。“另存为”的命令是=C-x C-w=。
Emacs has a sort of File Explorer named Dired. You can open Dired with the command C-x d
. You can move up and down in the Dired buffer by using p
and n
just as you can use C-p
and C-n
in any other buffer. You can still use the control key, but you do not have to.
Emacs有一种名为Dired的文件资源管理器。您可以使用=C-x d=命令打开Dired。可以使用=p=和=n=在Dired缓冲区中上下移动,就像可以在任何其他缓冲区中使用=C-p=和=C-n=一样。您仍然可以使用控制键,但不必这样做。
Here are a few of the most important Dired commands. 下面是一些最重要的Dired命令。
*Dired commandAction*RETVisit selected file (or directory)CCopyDDelete immediatelydMark for deletion. Use x
to carry out deletions.RRename a file!Specify a shell command to carry out on a file
*重新访问选定的文件(或目录)CCopyDDelete立即删除。使用=x=执行删除。RRename文件!指定要对文件执行的shell命令
Adding the following two lines to your .emacs
file will create an Open Recent submenu under the File menu.
将以下两行添加到=中。将在“文件”菜单下创建一个打开的“最近”子菜单。
(require 'recentf) (recentf-mode 1)
Buffers
*缓冲
属性: :CUSTOM_ID: buffers :CUSTOM_ID:缓冲区
结束:
The command C-x b
takes you to your previous buffer.
命令=C-x b=带您到前面的缓冲区。
The command C-x C-b
creates a new window with a list of open buffers. You can navigate this list much as you would the Dired buffer.
命令=C-x C-b=使用打开的缓冲区列表创建一个新窗口。您可以像使用Dired缓冲区一样浏览这个列表。
You can type the letter o
to open the file on the current line in another window. You can type the number 1
to open the file as the only window.
您可以键入字母=o=来打开另一个窗口中当前行的文件。您可以键入数字=1=打开文件作为唯一的窗口。
The command M-x kill-some-buffers
lets you go through your open buffers and select which ones to kill.
命令=M-x杀死一些缓冲区=允许您遍历打开的缓冲区并选择要杀死哪些缓冲区。
Windows
*的窗户
属性: :CUSTOM_ID: windows :CUSTOM_ID:窗户
结束:
The command C-x 1
closes all windows except the current one.
命令=C-x 1=关闭除当前窗口之外的所有窗口。
C-x 2
splits the current window horizontally, one buffer on top of the other.
=C-x 2=水平分割当前窗口,一个缓冲区在另一个缓冲区之上。
C-x 3
splits the current window vertically, one beside the other.
=C-x 3=垂直分割当前窗口,一个在另一个旁边。
C-x o
cycles through windows.
=C-x o=循环通过窗口。
Miscellaneous commands
*其他命令
属性: :CUSTOM_ID: misc :CUSTOM_ID misc
结束:
*CommandExplanation*=M-g g=Go to line number=M-==Report line and character count of region=M-/=Autocomplete based on text in current buffer=C-x C-e=Evaluate the Lisp expression to the left of the cursor=M-x eval-region=Evaluate the selected region as Lisp code=M-x shell=Run a shell inside Emacs=M-!=Run a single shell command=M-x sort-lines=Sort the lines in a region=M-x desktop-save=Save an Emacs session=C-t=Transpose characters=M-t=Transpose words, works across punctuation and tags *CommandExplanation*=M-g =返回行数=M-=报告行数和基于当前缓冲区中的文本的字符数=M-/=自动完成=运行单个shell命令=M-x排序-行=对一个区域内的行进行排序=M-x桌面-保存=保存Emacs会话=C-t=转置字符=M-t=转置单词,可以跨标点符号和标签工作
Emacs resources
Emacs资源
属性: :CUSTOM_ID: resources :CUSTOM_ID:资源
结束:
One program to rule them all\ Emacs cursor movement\ Emacs and Unicode\ Emacs kill (cut) commands\ Real Programmers (xkcd cartoon)\ 10 Specific Ways to Improve Your Productivity With Emacs from Steve Yegge 10种使用Emacs提高生产力的具体方法来自Steve Yegge