emacs 注册经常访问文件

如果你也像我那样经常用emacs访问相同的文件的话,用emacs的Register来注册你经常访问的文件,就可以用快捷键来访问他们了。不用每次都Ctrl+x Ctrl+F 找文件了。

(set-register r '(file . name))
(set-register ?e (cons 'file "~/.emacs"))
打开~/.emacs 就可以用命令 Ctrl+x r j e

Emacs manual

Emacs cheat sheet

Some handy emacs command you may want to know for improving your speed of coding.

backward-kill-sexp, this command Kill the balanced expression preceding point.  It is bound to ESC <C-backspace>. For example,

if (n > 0) {
   transfer(n - 1, pegs, use, to, from);
}

To remove the whole block of the code in the if condition, place your cursor at the end of the closing bracket and run the command backward-kill-sexp, The whole block of code will be deleted.

if (n > 0) 

backward-up-list, this command ‘Move backward out of one level of parentheses.’

Set mark and pop mark. This combination of commands allows you to navigate code easily by setting a mark. <C-SPC> which sets the mark and then  <C-u C-SPC> which jumps to the last one.

Multiple Emacs Shell Buffers

Having my work changed a lot during the last year, from a Lunix developer to a half developer half support and now are purely support, I do not have many chance to use Emacs that often anymore, but I keep to use to it as much as possible. After all it’s my first editor in my programmer career. One thing I like is its shell buffers. Unfortunately, It only support one shell as I thought before. Because if you type M-x shell to open a new shell buffer, if you already have one open that will just switch to the existing one.

Continue reading “Multiple Emacs Shell Buffers”

Use Regular Expressions in Emacs

What is Regular Expression? A regular expression is a special text string for describing a certain amount of text. Generally, A regular expression contains a few special characters and ordinary characters. If you have used Linux/Windows systems, you will probably familiar with wildcard notations such as *.txt to find all text files in a folder. That’s a simple regular expression example (Thanks for netcasper’s correcting . The regex equivalent to “.txt” is .*.txt). Nowadays, Most of the text editors support regular expression such as vi, emacs and Ultra Editor(not a free software). Today, I would like introduce some basic knowledge about regular expression and use it in Emacs to improve the efficiency of your coding work.

Continue reading “Use Regular Expressions in Emacs”