1、C-k 的功能并不是剪切当前行,而是剪切当前行从光标到行末的内容。

Emacs 中的剪切不叫剪切(cut),叫kill,复制(copy)不叫copy ,叫kill-ring-save (这个可以理解为先kill掉放到kill-ring里,然后再把它save回来)。另外还有一个操作叫delete ,delete 与kill的区别是kill掉的内容会被放到kill-ring(剪切环)而delete掉的内容则直接删掉了,除了进行undo操作外没法找回删掉的内容。而kill 掉的内容很容易从kill-ring中取回。有了kill-ring的Emacs可以说是具有了多个剪贴板。
默认的与kill yank delete 有关的键绑定。

  • C-w       kill-region
  • C-k       kill-line
  • C-M-k     kill-sexp 这个比较复杂 它表示删除一个结构单元。对不同类型的文档(c java文本 等)一个结构单元表示不同的含义。你可以尝试一下。(比如,你移动到一个括号的开头,按下,则删除整个括号内的内容)
  • C-d      delete-char
  • M-d      kill-word
  • C-backspace          backward-kill-word
  • M-w           kill-ring-save    复制。
  • C-y            yank 粘贴。
  • 另外在按下C-y后,按一次或多次M-y 会循环取出kill-ring中的内容,然后贴到当前位置 。
  • 但是kill-ring毕竟不是操作系统的剪切板,kill-ring里的内容是没法在其他程序里利用的。所以要用好它又设及到与系统剪切板的同步的问题了。 在Windows 上Emacs已经默认解决了这个问题。在linux上没有。因为Linux的剪切板不只一个。所以问题要复杂许多。

Linux 下 与系统系统剪切板相关的操作。

;;关于剪切板: X共享信息的有 clipboard primary secondary 三个区域;;其中clipboard 就是我们常说的剪切板,而primary 就是常说的selection ,也就是说只要你选中一段内容,;;那么这段内容就被存到primary 中了,而secondary 目前好像已经不推荐使用了,所以不用考虑;;而emacs 默认存在内容的区域不是上面任何一个,它叫kill-ring叫剪切环,它能存储不只一份内容,;;C-y 会取出kill-ring 中最近的一份内容,然后paste(专业点叫yank)到buffer 中,可以通过M-y;;取得以前的版本
(defun setting-for-linux-x-clipboard (&optional frame) 
(when (and (eq system-type 'gnu/linux)(eq (window-system frame) 'x)) 
;;在向kill-ring 加入内容的同时会执行interprogram-cut-function 变量指定的函数 
(setq-default interprogram-cut-function 'x-select-text);
; default ;;在执行yank 操作时,会检查interprogram-paste-function 变量 所指向的函数 ;;是否有返回值,如果有的话就将其yank在buffer 中,否则的话才会从kill-ring中取值 ;;而x-cut-buffer-or-selection-value 和x-select-text函数一样, ;;也会根据x-select-enable-clipboard 和x-select-enable-primary 的值 ;;决定是否从clipboard 和primary 中取得内容 
(setq-default interprogram-paste-function 'x-cut-buffer-or-selection-value) 
;;有关于往kill-ring加入内容时 是否往clipboard ,及primary 放入的判断 
(setq-default x-select-enable-clipboard t) 
;每一次往kill-ring 里加入东西时,同时往clipboard中放一份, 
(setq-default x-select-enable-primary nil) 
;每一次往kill-ring 里加入东西时,是否也往primary 中放入 
(setq-default select-active-regions t)
;这个忘了什么意思 ;;在轮询kill-ring 的时候是否也同步改变系统的clipboard primary ;;(要根据x-select-enable-clipboard ,及x-select-enable-primary的值决定哪个会被改变) 
(setq-default yank-pop-change-selection t) 
;;;Save clipboard strings into kill ring before replacing them 
(setq-default save-interprogram-paste-before-kill t) 
;; make mouse middle-click only paste from primary X11 selection, not clipboard and kill ring. ;;鼠标中键粘贴,只考虑X11中的selection ,不考虑clipboard 和emacs 中的kill-ring 
(global-set-key [mouse-2] 'mouse-yank-primary)
;;其实有了以上几个配置 下面这三个键完全没有必要,但为防万一, ;;将与剪切板相关的三个操作绑到这三个不常用的键上. 
(global-set-key [(shift delete)] 'clipboard-kill-region) 
(global-set-key [(control insert)] 'clipboard-kill-ring-save)
(global-set-key [(shift insert)] 'clipboard-yank) ) )

=============================================================================================
二、set key Bindings

M-x global-set-key <RET> key cmd <RET>
Define key globally to run cmd.       example:   M-x global-set-key <RET> C-z shell <RET>
M-x local-set-key <RET> key cmd <RET>
Define key locally (in the major mode now in effect) to run cmd
M-x global-unset-key <RET> key
Make key undefined in the global map. 
M-x local-unset-key <RET> keyMake key undefined locally (in the major mode now in effect).

============================================================================================

三、Emacs中文输入法切换设置

Emacs中默认Ctrl+Space或Ctrl+@设置选择标记(set-mark). 这对非英语国家用户来说,不太方便。因为Windows下Ctrl+Space切换输入法。而在Emacs中按Ctrl+@又太累(要按Shift呀)。
解决办法是:Emacs中改用Shift+Space设置标记(set-mark)。
把下边这行加入到~/.emacs中:
;;; hzh add for set mark,我用的是prelude,所以这些应该放在prelude-modules.el里
;;; below add by hzh
;;; create a directory named ".emacs-hzh.d" in home dir, and put all your personal
;;; files(or directories) in it, we will add it to load-path. If you hava a theme,
;;; you should make a dir named "themes", and put theme files in it.
 
(defun hzh-add-subfolders-to-load-path (parent-dir)
  "Add all level PARENT-DIR subdirs to the `load-path'."
  (dolist (f (directory-files parent-dir))
    (let ((name (expand-file-name f parent-dir)))
      (when (and (file-directory-p name)
                 (not (equal f ".."))
                 (not (equal f ".")))
        (add-to-list 'load-path name)
        (hzh-add-subfolders-to-load-path name)))))
 
(defun hzh-add-subfolders-to-custom-theme-load-path (parent-dir)
  "Add all level PARENT-DIR subdirs to the `custom-theme-load-path'."
  (dolist (f (directory-files parent-dir))
    (let ((name (expand-file-name f parent-dir)))
      (when (and (file-directory-p name)
                 (not (equal f ".."))
                 (not (equal f ".")))
        (add-to-list 'custom-theme-load-path name)
        (hzh-add-subfolders-to-custom-theme-load-path name)))))
 
(defvar hzh-emacs.d ".emacs-hzh.d")
(defvar hzh-loadpath (expand-file-name hzh-emacs.d (getenv "HOME")))
(defvar hzh-theme-loadpath (expand-file-name "themes" hzh-loadpath))
(hzh-add-subfolders-to-load-path hzh-loadpath)
(add-to-list 'custom-theme-load-path hzh-theme-loadpath)
(hzh-add-subfolders-to-custom-theme-load-path hzh-theme-loadpath)
 
;; hzh add for theme
(disable-theme 'zenburn)
;; (load-theme 'solarized-dark t t)
;; (enable-theme 'solarized-dark)
;; (load-theme 'monokai t t)
;;; (setq molokai-theme-kit t)
(load-theme 'molokai t t)
(enable-theme 'molokai)
 
;;; hzh add for ibus
;;; ibus-el 似乎使用的是python2
(require 'ibus)
(setq ibus-python-shell-command-name "python2.7")
;; Turn on ibus-mode automatically after loading .emacs
(add-hook 'after-init-hook 'ibus-mode-on)
 
;;; hzh add for ibus settings
;; Use C-SPC for Set Mark command
;; (ibus-define-common-key ?\C-\s nil)
;; Use C-/ for Undo command, hzh: ibus will not change Undo
(ibus-define-common-key ?\C-/ nil)
(ibus-define-common-key [?\S- ] nil)
;; Change cursor color depending on IBus status
(setq ibus-cursor-color '("red" "blue" "limegreen"))
(global-unset-key (kbd "C-SPC"))
(global-set-key (kbd "C-SPC") 'ibus-toggle)
 
;;; hzh add for set mark
(global-set-key [?\S- ] 'set-mark-command)
(global-set-key (kbd "M-n") 'set-mark-command)
;(custom-set-variables '(default-input-method "chinese-py"))
 
;;; hzh add for scroll bar
(toggle-scroll-bar -1)
 
;;; hzh add for line number
(global-linum-mode t)
(display-time-mode t)
 
;;; hzh add for goto-line
(global-set-key [f8] 'goto-line)
 
四、Emacs中文输入法切换设置
输入法
没有了中文输入法, Emacs 对於中文使用者一点用处都没有。想要知道您可以使用哪些输入法,您可以键入 C-x RET C-\ SPC ,接著 Emacs 会出现一个所有多国语文的输入法列表窗格。然后您就可以在其中键入您所使用的输入法名称了。下面是作者的作法:(作者使用的是行列输入法,名称为 chinese-array30 。)
 
1. 设定预设的输入法,将下面这一行加入到 ~/.emacs 档案中:
 
(custom-set-variables '(default-input-method "chinese-array30"))
 
这样子在启动 Emacs 后,您就可以直接以 C-\ 指令在英文输入和行列输入法之间切换了。
 
2. 但是有时候用行列打不出来,需要切换成注音输入法。   有两种方式可以达成这个目的:
 
   a. C-x RET C-\ chinese-zozy RET
   b. C-u C-\ chinese-zozy RET
 
作者建议您使用第二种方式,因为它同时也是作为两种输入法间切换的指令。接下来您只要键入 C-u C-\ RET 就可以在行列和注音这两者间作切换了。(注意:中英输入法间的切换还是以 C-\ 指令为之。)
以后我们在不同中文输入法间作切换将可以 C-u C-u C-\ 达成,原本作者是建议以 M-\ 来补足这个想法,但是 M-\ 很不幸已经作为 delete-horizontal-space 指令了。不然 C-\ 搭配 M-\ 不是很漂亮吗?
这样子您应该可以理解如何使用中文输入环境了吧!当然,您必须将行列改为自己喜欢的输入法。
 
如果您找不到自己喜欢的输入法,那么您可以:
 
1. 自己造一个(相关文献在  .../emacs/leim/quail/ 。)
2. 利用现成的输入法档案做出一个
   ( .../emacs/lisp/international/titdic-cnv.el 。)
   只要是 cxterm 的 *.tit 和 xcin 的 *.cin   有提供的输入法都可以。
   但是作法上对於终端使用者而言并不十分“自动”,   因此现阶段可能还是需要志愿者协助进行才有办法。
 
不知道 cxterm 和 xcin 的开发人员是否可以协助提供。(对了, cxterm 的行列输入法有个小臭虫,应该和谁联系?)
 
======================================================================
 
auto completion:
M-/                       (hippie-expand)                        #(global-set-key (kbd "M-/")  'hippie-expand)

Bookmark:
C-x r m RET                              Set the bookmark for the visited file, at point.

C-x r m bookmark RET            Set the bookmark named bookmark at point (bookmark-set).
C-x r b bookmark RET            Jump to the bookmark named bookmark (bookmark-jump).
C-x r l                                        List all bookmarks (list-bookmarks).
M-x bookmark-delete RET bookmark RET                    Delete the bookmark named bookmark.

View Mode:

M-x view-buffer prompts for an existing Emacs buffer, switches to it, and enables View mode. 
Typing e (View-exit) disables View mode.

 Follow Mode:

To use Follow mode, go to a frame with just one window,split it into two side-by-side windows using C-x 3, and then type M-x follow-mode.To turn off Follow mode, type M-x follow-mode a second time.

M-s        (sp-splice-sexp) unwrap the list, example:    (foo (bar| baz) quux) -> (foo bar| baz quux),附加的,与follow mode不相关。
 
Multiple buffers:

C-x b buffer RET                Select or create a buffer named buffer (switch-to-buffer).
C-x C-b RET                        Popup a window to Select buffer (ibuffer). 
C-x 4 b buffer RET            Similar, but select buffer in another window (switch-to-buffer-other-window).
C-x 5 b buffer RET            Similar, but select buffer in a separate frame (switch-to-buffer-other-frame).
C-x LEFT                            Select the previous buffer in the buffer list (previous-buffer).
C-x RIGHT                         Select the next buffer in the buffer list (next-buffer).
C-x k                                  C-x k runs the command ido-kill-buffer
C-x b buffername C-k         kill buffer in background

Multiple windows:
C-x 2                                (split-window-below) Split the selected window into two windows, one above the other
C-x 3                                 (split-window-right)   Split the selected window into two windows, positioned side by side

C-x o                                 Select another window (other-window)     (包含 C-x O: 移动到上一个window,命令为 other-window -1)
C-x 1                                 runs the command delete-other-windows

C-x 4 b bufname RET     Select buffer bufname in another window (switch-to-buffer-other-window)

C-x 4 f filename RET      Visit file filename and select its buffer in another window (find-file-other-window)

C-x 4 r filename RET      Visit file filename read-only, and select its buffer in another window (find-file-read-only-other-window)
C-x 4 d directory RET    Select a Dired buffer for directory directory in another window (dired-other-window)

C-x 4 0                             Delete the selected window and kill the buffer that was showing in it (kill-buffer-and-window)

C-x ^                                 Make selected window taller (enlarge-window)

C-x }                                 Make selected window wider (enlarge-window-horizontally)
C-x {                                 Make selected window narrower (shrink-window-horizontally)
C-x -                                 Shrink this window if its buffer doesn’t need so many lines (shrink-window-if-larger-than-buffer)
C-x +                                 Make all windows the same height (balance-windows)
C-u 10 C-x ^                    Make selected window taller (enlarge-window) with 10 lines(带参数的形式)

Moving by Defuns:

C-M-a                                Move to beginning of current or preceding defun (beginning-of-defun),就是移动到函数头

C-M-e                                 Move to end of current or following defun (end-of-defun),移动到函数尾部
C-M-h                              Put region around whole current or following defun (mark-defun),选择整个函数

Imenu:

M-x imenu                       it reads the name of a definition using the minibuffer, then moves point to that definition.寻找函数定义位置

Indenting Several Lines:

C-M-q                         Reindent all the lines within one parenthetical grouping(c-indent-exp),即在光标移到{上,然后按键

Searching with Grep under Emacs:
M-x lgrep                      异步查找
M-x grep                      在当前目录进行grep,

M-x grep-find                find and grep
M-x find-grep                find and grep
M-x rgrep                      find and grep

M-x kill-grep                    Kill the running grep subprocess

Running Compilations under Emacs:

M-x compile             Run a compiler asynchronously under Emacs, with error messages going to the *compilation* buffer
M-x recompile         Invoke a compiler with the same command as in the last invocation of M-x compile 
M-x kill-compilation    Kill the running compilation subprocess

If you change the variable compilation-auto-jump-to-first-error to a non-nil value, Emacs automatically visits the locus of the first error message that appears in the *compilation* buffer. 

Running Debuggers Under Emacs:

The GUD (Grand Unified Debugger) library provides an Emacs interface to a wide variety of symbolic debuggers. It can run the GNU Debugger (GDB), as well as DBX, SDB, XDB, Perl’s debugging mode, the Python debugger PDB, and the Java Debugger JDB.
M-x gdb        
M-x gdb-many-windows             works after M-x gdb

C-x SPC                                        Set a breakpoint on the source line that point is on (gud-break), 必须在gdb minor模式用
(附注: gdb 里设置LD_LIBRARY_PATH的方法:   set  environment  LD_LIBRARY_PATH  ****)
(gdb>  set args xxx   #給執行程式參數xxx,必须在run之前;   或者 gdb>  run param1 param2 param3)
(gdb> ptype ***valuavle)    # print out the definition of a struct or class
(gdb> print *(struct mystruct *)  0x8002bf20) #可以pretty打印某个struct的内容

Dired, the Directory Editor:
Dired makes an Emacs buffer containing a listing of a directory, and optionally some of its subdirectories as well. You can use the normal Emacs commands to move around in this buffer, and special Dired commands to operate on the listed files.
C-x C-d         (list-directory) list files in a directory, but it is not Dired
C-x d             (dired) invoke Dired

Reading Mail with Rmail:

emacs 操作集锦的更多相关文章

  1. Eclipse for Java EE软件操作集锦(二)

    看本文章之前请确保已经了解eclipse建立web工程,如果有疑问请查看本系列文章第一篇 eclipse软件操作集锦(一) 1.我们添加一个servlet 配置一下web.xml测试一下是否能正常显示 ...

  2. delphi关于文件操作集锦

        关于文件操作集锦 取得该快捷方式的指向EXE关键词:快捷方式 LNK unit Unit1; interface usesWindows, Messages, SysUtils, Varian ...

  3. Eclipse for Java EE软件操作集锦(一)

    以下是我在Java网站开发过程中,关于软件操作Eclipse中,遇到的一些问题并提供了解决方案.一.java web开发使用的集成开发工具是eclipse for Java EE 官方下载地址:htt ...

  4. php数组操作集锦- 掌握了数组操作, 也就掌握了php

    参考下面的文章, 是很好的: http://www.cnblogs.com/staven/p/5142515.html http://pcwanli.blog.163.com/blog/static/ ...

  5. php字符串操作集锦

    web操作, 主要就是对字符文本信息进行处理, 所以, 字符串操作几乎占了很大一部分的php操作.包括 注意strstr 和 strtr的区别? 前者表示字符串查找返回字符串,后者表示字符串中字符替换 ...

  6. XML文档操作集锦(C#篇)

    在JSON没流行起来的时候xml一直作为程序存储配置信息的主流介质:特别是小型数据表方面还是不错的选择,所以经常涉及到的操作无非也就是增删改查,这篇博客主要是对这些对比较常用的操作做了个简单的总结 文 ...

  7. Microsoft Dynamics CRM 2011/2013 JS操作集锦

    1.Xrm.Page.context用户ID:getUserId()用户角色:getUserRoles()用户语言:getUserLcid()组织名称:getOrgUniqueName()组织语言:g ...

  8. sql语句操作集锦

    SQL操作全集 下列语句部分是Mssql语句,不可以在access中使用. SQL分类: DDL—数据定义语言(CREATE,ALTER,DROP,DECLARE) DML—数据操纵语言(SELECT ...

  9. Microsoft Dynamics CRM 2011 JS操作集锦

    1.Xrm.Page.context 用户ID:getUserId() 用户角色:getUserRoles() 用户语言:getUserLcid() 组织名称:getOrgUniqueName() 组 ...

随机推荐

  1. [POJ1159]Palindrome(dp,滚动数组)

    题目链接:http://poj.org/problem?id=1159 题意:求一个字符串加多少个字符,可以变成一个回文串.把这个字符串倒过来存一遍,求这两个字符串的lcs,用原长减去lcs就行.这题 ...

  2. Python3 学习第十一弹: 模块学习四之sys库

    sys模块 提供一些与python解释器关系紧密的变量和函数 1> argv 命令行参数 通过命令行可以向python传输参数 2> exit([arg]) 程序退出,可以返回给命令行一个 ...

  3. Qt之等待提示框(QPropertyAnimation)

    简述 之前分享过QLabel可以通过QMovie播放gif图片,可以实现等待提示框,今天主要使用动画QPropertyAnimation来进行实现! 数据加载的时候,往往都需要后台线程进行数据请求,而 ...

  4. window.location.href 放置在单独的JS文件中使用时问题

    场景:假设当前浏览器地址栏的地址是:http://localhost:8888/SSHBoot/tourist/homeMainAction_signInUI.do, 现在我想在点击按钮时定位到“ht ...

  5. 优雅地使用CodeIgniter 3之Session类库(1)(转)

    相信无数人在使用CI2的Session类库时,遇到各种的坑,各种抱怨,各种不解.在CI中国论坛能搜到大量关于Session类库的提问,说明要想用 好session类库还是得下一番功夫.本文将先从CI2 ...

  6. 【J2EE性能分析篇】JVM参数对J2EE性能优化的影响

    一切J2EE应用都是基于JVM的,那么对于JVM的设置和监控,成为J2EE应用程序性能分析和性能优化的必然手段.今天Sincky和大家交流该话题.这里以Tomcat环境为例,其它WEB服务器如Jbos ...

  7. django - raw sql - 注意点!

    现在的自己已经不怕mysql,已经熟悉了sql “搜索优化专家有时候都无法顾全所有,更何况ORM” 两种方法执行 sql原生语句 tablename.objects.raw() - 这样的语句,只能执 ...

  8. scala学习笔记(6):闭包

    到本章这里,所有函数文本的例子仅参考了传入的参数.例如,(x: Int) => x > 0里,函数体用到的唯一变量,x > 0,是x,被定义为函数参数.然而也可以参考定义在其它地方的 ...

  9. 手机GUI自动化测试介绍

    手机GUI自动化测试介绍 Posted on 2013/05/15 Xing Binbin(测试工程师) 摘要 众所周知,自动化测试可以一定程度上减轻测试人员负担,提高测试效率,并且通过自动化还可以实 ...

  10. .htaccess 文件的使用

    用于服务器对文件夹的控制 官方解释为 :分布式配置文件 ,提供了针对目录改变配置的方法; 项目可以有多个这样的配置文件,子目录文件会覆盖父目录的配置 在apache(这里泛指服务器)中,/conf/v ...