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 ...
随机推荐
- string与int互换
1:将string转化为int 1.) int i = Integer.parseInt(String s); 2.) int i = Integer.valueOf(my_str).intValue ...
- 虚拟机主机能互相ping通,但是无法远程连接
首先将虚拟机关机,找到Edit virtual machine Settings(编辑虚拟机设置)
- 详细讲述MySQL中的子查询操作 (来自脚本之家)
继续做以下的前期准备工作: 新建一个测试数据库TestDB: ? 1 create database TestDB; 创建测试表table1和table2: ? 1 2 3 4 5 6 7 8 9 1 ...
- trigger() --工作中问题nav样式
自动执行某元素的某个事件 $("#div").trigger("click"); //让系统自动执行单击事件 适用于nav样式中,下面横线绝对定位于nav.o ...
- sping注解
1.@Autowired(已不推荐使用) 按类型装配,如果匹配不到或者匹配到多个则抛BeanCreationException异常.如果是多个时可以用@Qualifier指定来解决 eg. @Auto ...
- Apple、Google、Microsoft的用户体验设计原则
轻巧的Apple 注重设计过程: 在设计过程中引入用户交互的5个目标: 了解您的目标客户 分析用户的工作流 构造原型系统 观察用户测试 制定观察用户准则 做出设计决定 避免功能泛滥 80% 方案 优秀 ...
- three.js立方体
<!DOCTYPE html> <html lang="en"> <head> <title>three.js webgl - ge ...
- 每天一个linux命令--批处理
简单来说awk就是把文件逐行的读入,以空格为默认分隔符将每行切片,切开的部分再进行各种分析处理. 创建批处理脚本wanghy.sh: #!/bin/sh cd /opt/virgo-tomcat-se ...
- 浅谈CSS hack(浏览器兼容)
今天简单写一点关于浏览器兼容的处理方法,虽然百度上已经有很多,但是我还是要写! 先看一个图 这个图描述了2016年1月至8月网民们所使用的浏览器市场份额(来源:http://tongji.baidu. ...
- [转] 前后端分离开发模式的 mock 平台预研
引入 mock(模拟): 是在项目测试中,对项目外部或不容易获取的对象/接口,用一个虚拟的对象/接口来模拟,以便测试. 背景 前后端分离 前后端仅仅通过异步接口(AJAX/JSONP)来编程 前后端都 ...