Emacs 配置文件
以下是我整理的 emacs 配置文件,供刚开始玩 emacs 的同学参考。网上有人说:emacs 是神的编辑器,如果能够用到这样的编辑器,那这个人就是神了。从我个人的经验来看,emacs 是一把利器,用好它,将会事半功倍。我们大多数的编程是受制于语言(程序员是语言的奴隶),而如果能够掌握好 emacs 这一利器,则对于自己是一个质的飞跃——编程是让语言成为程序员的奴隶。这一点,以后详细谈。
;; 常规设置
(menu-bar-mode -1) ;; 不显示菜单
(tool-bar-mode -1) ;; 不显示工具栏
(scroll-bar-mode -1) ;; 不显示滚动条
(column-number-mode 1) ;; 显示行数和列数
(setq default-directory "d:/home/") ;; 设置默认目录
(appt-activate 1) ;; 启动日历提醒
(setq require-final-newline t) ;; 编辑文件的最后一个字符是回车
(setq bookmark-default-file "~/.emacs.d/.emacs.bmk") ;; 书签文件位置
(fset 'yes-or-no-p 'y-or-n-p) ;; 简化确认时的输入
(global-set-key "\r" 'newline-and-indent) ;; 回车默认缩进
(setq inhibit-startup-message t) ;; 不显示启动时的界面
(show-paren-mode 1) ;; 显示括号的对应反括号
(setq show-paren-style 'mixed) ;; 设置显示括号的样式
(mouse-avoidance-mode 'animate) ;; 光标与鼠标重合时,移开鼠标
(setq frame-title-format "%b -- Do It Yourself") ;; 设置标题
(setq default-tab-width 4) ;; Tab 的宽度为 4
(setq-default make-backup-files nil) ;; 不产生备份文件
(set-frame-position (selected-frame) 400 140) ;; 设置初始的窗口宽高 ;; 增强 find file 及 switch buffer 功能
(require 'ido)
(ido-mode t) ;; 启动 Emacs 服务,下次打开文件时使用同一个 Emacs
(server-start) ;; 设置环境变量
(setenv "LC_CTYPE" "zh_CN.UTF-8") ;; 设置全局快捷键
(global-set-key "\C-c\C-v" 'view-mode) ;; 只读模式
(global-set-key "\C-z" 'set-mark-command) ;; Mark
(global-set-key "\C-xz" 'suspend-frame) ;; 将 Emacs 放到后台运行
(global-set-key [f8] 'occur) ;; 在当前 Buffer 中查找
(global-set-key "\C-x\C-b" 'electric-buffer-list) ;; 列出当前所有 Buffer
(global-set-key (kbd "C--") 'undo) ;; 向前恢复
(global-set-key "\C-c\C-z" 'pop-global-mark) ;; 到之前的 Marker
(global-set-key "\M-/" 'hippie-expand) ;; 智能完成
(global-set-key (kbd "C-SPC") 'nil) ;; 将 C+空格 快捷键置空
(global-set-key "\C-ca" 'org-agenda) ;; 启用 Agenda 模式
(global-set-key "\C-\\" 'toggle-truncate-lines) ;; 切换换行模式 ;; 设置 Windows 下字体
(setq w32-charset-info-alist
(cons '("gbk" w32-charset-gb2312 . 936) w32-charset-info-alist))
(setq default-frame-alist
(append
'((font . "fontset-gbk")) default-frame-alist))
(create-fontset-from-fontset-spec
"-outline-Courier New-normal-r-normal-normal-13-97-96-96-c-*-fontset-gbk")
(set-fontset-font
"fontset-default" nil
"-outline-新宋体-normal-r-normal-*-14-*-96-96-c-*-iso10646-1" nil 'prepend)
(set-fontset-font
"fontset-gbk" 'kana
"-outline-新宋体-normal-r-normal-*-14-*-96-96-c-*-iso10646-1" nil 'prepend)
(set-fontset-font
"fontset-gbk" 'han
"-outline-新宋体-normal-r-normal-*-14-*-96-96-c-*-iso10646-1" nil 'prepend)
(set-fontset-font
"fontset-gbk" 'cjk-misc
"-outline-新宋体-normal-r-normal-*-14-*-96-96-c-*-iso10646-1" nil 'prepend)
(set-fontset-font
"fontset-gbk" 'symbol
"-outline-新宋体-normal-r-normal-*-14-*-96-96-c-*-iso10646-1" nil 'prepend)
(set-default-font "fontset-gbk") ;; 增加 Eshell 命令
;; linux 中 clear
(defun eshell/clear ()
"to clear the eshell buffer."
(interactive)
(let ((inhibit-read-only t))
(erase-buffer))) ;; 用 Windows 文件浏览器打开
(defun eshell/o (&rest args)
"open the doc"
(interactive)
(if (eq nil args)
(setq args '("explorer" ".")))
(apply 'start-process-shell-command "Sub process of Eshell" "*Messages*"
(car args) (cdr args))) ;; 恢复默认宽高设置
(defun retrive-position ()
(interactive)
(set-frame-position (selected-frame) 400 140)
(set-frame-size (selected-frame) 80 40)) ;; 还原最大化窗口
(defun frame-restore ()
"Restore a minimized frame"
(interactive)
(w32-send-sys-command 61728)) ;; 最大化窗口
(defun frame-maximize ()
"Maximize the current frame"
(interactive)
(w32-send-sys-command 61488)) ;; 关闭 Buffer,支持 Server/Client 模式的关闭
(defun my-kill ()
"Kill buffer for server-client and not server-client."
(interactive)
(cond (server-buffer-clients (server-edit))
(t (ido-kill-buffer)))) ;; 设置关闭 Buffer 的快捷键
(global-set-key "\C-xk" 'my-kill) ;; 加入 package 模块,可以通过 list-package 添加扩展
(require 'package)
(package-initialize)
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/")) ;; 设置假期,在日历中可以看到
(setq calendar-holidays '((holiday-chinese 1 1 "春节")
(holiday-chinese 1 15 "元宵节")
(holiday-fixed 3 8 "妇女节")
(holiday-fixed 5 1 "劳动节")
(holiday-fixed 6 1 "儿童节")
(holiday-chinese 5 5 "端午节")
(holiday-chinese 7 7 "七夕节")
(holiday-chinese 7 15 "鬼节")
(holiday-fixed 8 20 "纪念")
(holiday-chinese 8 15 "中秋节")
(holiday-chinese 9 9 "重阳节")
(holiday-fixed 10 1 "国庆节") (holiday-chinese 1 1 "张三生日")
(holiday-chinese 3 1 "李四生日"))) ;; 设置多窗口时的快捷键,Shift+方向可以切换窗口,C-c ← 可以回到前一次窗口设置
(when (fboundp 'winner-mode)
(winner-mode)
(windmove-default-keybindings))
在 windows 环境中,添加 emacs 的右键编辑菜单,新建一个 emacs.reg 文件,内容如下:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\emacs]
@="Emacs (&W)"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\emacs\command]
@="D:\\emacs\\bin\\emacsclientw.exe -a \"d:\\emacs\\bin\\emacsclientw.exe\" \"%1\""
编辑完后,双击 emacs.reg 即可将该配置写入到注册表,这样,右键菜单就会有一个 Emacs(W) 的东东。可以通过这个选项使用 emacs 打开任何文件。
Emacs 配置文件的更多相关文章
- 转来的emacs配置文件,自动安装插件
网上转来的emacs配置文件,便于自动安装插件,收藏起来 http://www.gogae.org/post-7/ EMACS是一个伪装成代码编辑器的操作系统. EMACS是一个非常强大的代码编辑器, ...
- emacs配置文件的基础知识 (转载)
转自:http://blog.csdn.net/schumyxp/article/details/2278268 emacs的配置文件,叫作.emacs,是个隐藏文件,存在于当前用户的根目录下面,也就 ...
- linux下emacs配置文件
1:安装.在ubuntu下使用命令 sudo apt-get install emacs,即可,我使用的是ubuntu的10.04的版本,在里面使用了据说是163的2个源. 1.1:如何更新快速的源, ...
- Emacs配置文件
;;tab and space;;when true,emacs use mixture of tab and space to archieve(setq-default indent-tabs-m ...
- update:我的Emacs配置文件
;;设置字体用的 防止中文变成无法识别的框框 (set-default-font "Consolas-11") (set-fontset-font "fontset-d ...
- 我的Emacs配置文件
(custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you co ...
- ~/.emacs emacs 配置文件
windows ~/.emacs (when (>= emacs-major-version 24) (require 'package) (add-to-list 'package-archi ...
- [备份]Emacs配置文件
(set-background-color "gray20")(set-foreground-color "wheat") (tool-bar-mode -1) ...
- emacs配置详解及C/C++IDE全功能配置演示(附配置文件)
我的emacs插件下载地址: http://pan.baidu.com/share/link?shareid=4196458904&uk=3708780105 说明: 1.为什么使用emacs ...
随机推荐
- cocos2d-x 从win32到android移植的全套解决方案
引言:我们使用cocos2d-x引擎制作了一款飞行射击游戏,其中创新性地融入了手势识别功能.但是我们在移植过程中遇到了很多的问题,同时也发现网上的资料少而不全.所以在项目行将结束的时候,我们特地写了这 ...
- android shape的使用(转)
shape用于设定形状,可以在selector,layout等里面使用,有6个子标签,各属性如下: <?xml version="1.0" encoding="ut ...
- 数据结构0103汉诺塔&八皇后
主要是从汉诺塔及八皇后问题体会递归算法. 汉诺塔: #include <stdio.h> void move(int n, char x,char y, char z){ if(1==n) ...
- 【iOS 单例设计模式】底层解析与运用
[iOS 单例设计模式]底层解析与运用 一.单例设计名词解释: (官方解释)单例模式确保一个类只有一个实例,自行提供这个实例并向整个系统提供这个实例.(形象比喻)程序 — 公司 单例实例 - 管理 ...
- 【iOS [[UIApplication sharedApplication] delegate]】运用
之前想要拿到app的窗口,我们通常的写法是: [UIApplication sharedApplication].keyWindow 这种写法之前一直也觉得是正确的,没什么问题,而且网上大多数的博客或 ...
- POI的入门
POI快速入门 POI开发需要的七个步骤: 1.创建工作薄WorkBook对象 Workbook wb = new HSSFWorkbook(); //它是操作excel 2003版本 2.创建一个工 ...
- VS2012 还原默认设置
恢复默认设置的2种方法 如果VS出现问题或设置变乱,可以通过恢复默认设置使之回到安装成功时的状态,从而解决出现的问题.VS恢复默认设置的方法有2种,分别是:通过"导入和导出设置"实 ...
- JAVA 引入 junit工具框架
我遇到的麻烦 : 开始直接按照视频上的来做,直接也是引入的他上面的jar ,但是我只引入了一个,就是上面的junit-4.4.jar,然后就会报错,会出现,空指针的错误, 后面我又按照网上的教程 这里 ...
- python基础04 运算
数学运算 print 2+2 #加法 print 1.3-4 #剪法 print 3*5 #乘法 print 4.5/1.5 #除法 print 3**2 #乘方 print 10%3 #求 ...
- [翻译svg教程]svg中的circle元素
svg中的<circle> 元素,是用来绘制圆形的,例如 <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink= ...