敏捷之道——提高命令行编辑速度
来源:互联网 发布:java泛型t 基本类型 编辑:程序博客网 时间:2024/04/30 07:52
1. Motion and Objects
Characters
- C-f
forward-char
. Moves forward (to the right) over a character.- C-b
backward-char
. Moves backward (to the left) over a character.
Words
- M-f
forward-word
. Moves forward over a word.- M-b
backward-word
. Moves backward over a word.
Lines (vertically)
- C-n
next-line
. Moves down to the next line.- C-p
previous-line
. Moves up to the previous line.
Lines (horizontally)
- C-a
beginning-of-line
. Moves to the beginning of the current line.- C-e
end-of-line
. Moves to the end of the current line.
2. Deleting, Killing and Yanking
Emacs' deletion commands are also based on the textual objects above. But first, a terminological distinction: Deletion means to remove text from the buffer without saving it; most deletion commands operate on small amounts of text. Killing means to save the removed text, so that it can be yanked back later someplace else.Killed text is saved on the kill ring. The kill ring holds the last N kills, where N is 30 by default, but you can change it to anything you like by changing the value of the variable kill-ring-max. The kill ring acts like a fifo when you're killing things (after the 30th kill, kill number one is gone), but like a ring when you're yanking things back (you can yank around the ring circularly). kill-ring-maxdoesn't apply to the amount of text (in bytes) that can be saved in the kill ring (there's no limit), only to the number of distinct kills.
Characters
- C-d
delete-char
. Deletes the character to the right of (under, if the cursor is a block that covers a character) the cursor.- DEL
delete-backward-char
. Deletes the character to the left of the cursor.
说明:DEL是指backspace键
Words
- M-d
kill-word
. Kills to the end of the word to the right of the cursor (forward).- M-DEL
backward-kill-word
. Kills to the beginning of the word to the left of the cursor (backward).
Lines (horizontally)
- C-k
kill-line
. Kills to the end of the current line, not including the newline. Thus, if you're at the beginning of a line it takes two C-k's to kill the whole line and close up the whitespace.- C-u
kill-line
. Kills to the beginning of the current line, not including the newline.
3. Infinite Undo with Redo
One of the most important Emacs commands isundo
, invoked with C-_ (control underbar). C-_ is a valid ASCII character, but some keyboards don't generate it, so you can also use C-x u -- but it's more awkward to type, since it's a two-character command.The undo command allows you to undo your editing, back in time. It's handy when you accidentally convert all of a huge file to uppercase, say, or delete a huge amount of text. One keystroke changes everything back to normal.
We say Emacs has infinite undo because, unlike some editors, you can undo a long chain of commands, not just one previous one, even undoing through saves. We say Emacs has redo because you can reverse direction while undoing, thereby undoing the undo.
Once you get used to this feature you'll laugh at any editor that doesn't have it (unless you're forced to use it...). It's very important to get comfortable with undo as soon as possible; I recommend reading the undo section of the manual carefully and practising.
4. Searching and Replacing
Emacs has a variety of unusual and extremely powerful search and replace commands. The most important one is called incremental search. This is what the commandisearch-forward
, bound to C-s, does: it searches incrementally, one character at a time, as you type the search string. This means that Emacs can often find what you're looking for before you have to type the whole thing. To stop searching, you can either hit RET or type any other Emacs command (which will both stop the search and execute the command). You can search for the next match at any point by typing another C-s at any point; you can reverse the search by typing C-r; and you can use DEL to delete and change what you're searching for.isearch-backward
, bound to C-r, works the same way, but searches backward. (Use C-r to search for the next match and C-s to reverse the search.)
Occasionally you may want to search non-incrementally (though I rarely do). You can do this by typing C-s RET text RET, where text is the text to search for.
Much more useful is word search, which lets you search for a sequence of one or more words, regardless of how they're separated (e.g, by any number and combination of newlines and whitespace). To invoke word search, type C-s RET C-w word word word RET.
Emacs can also search incrementally (or not) by regular expressions; this is an extremely powerful feature, but too complex to describe here.
- 敏捷之道——提高命令行编辑速度
- 敏捷开发免费管理工具——火星人预览之二:编辑故事,产品管理,组织结构
- 提高页面加载速度之图片优化
- ArrayList——ensureCapacity()提高ArrayList的初始化速度
- 提高开发速度——Eclipse/STS 常用快捷键
- 网页优化技巧 — 提高页面打开速度
- Magento性能优化—开Gzip提高网页下载速度
- 提高XCode的编译链接速度—XCode编译速度慢的解决方案
- linux命令——命令行编辑(快捷键,技巧)
- 强悍的命令行 —— 编辑出错的命令
- 命令行编辑
- 我在敏捷之旅西安站的话题——分布式设计团队的敏捷之道
- 敏捷与速度
- 强悍的 Linux —— 强悍的命令行 —— 命令行编辑快捷键
- 企业级敏捷之道
- 敏捷开发之道
- 敏捷开发之道
- 敏捷之旅——杭州站
- leftnoteasy:机器学习中的数学(6)-决策树模型组合之随机森林与GBDT
- 初来乍到
- Spring Security
- C++学习总结_改变指针变量的地址
- selinux 常用指令
- 敏捷之道——提高命令行编辑速度
- p2p.download.Downloader
- 第一部分:基础知识(第一章)颜色主题
- 老人与死神
- Creating AppWidget in Android, part 1
- 单元测试mock:用JMockit写单元测试实例
- static
- jquery插件jquery.autocomplete.js的中文化、json化改造
- 医生与病人