emacs format
格式化源码是很常见的需求,emacs有个indent-region函数用于格式化选定的代码,前提是你处在某个非text mode下,如c-mode或者java-mode之类。如果要格式化整个文件,你需要先选定整个文件(C-x-h),然后调用indent- region(或者 C-M-\ )。两个命令总是麻烦,我们可以定义个函数搞定这一切,并绑定在一个特定键上,实现一键格式化:
(defun indent-whole ()
(interactive)
(indent-region (point-min) (point-max))
(message "format successfully"))
;;绑定到F7键
(global-set-key [f7] 'indent-whole)
将这段代码添加到你的emacs配置文件(~/.emacs),重启emacs,以后格式化源码都可以用F7一键搞定。
emacs format的更多相关文章
- [emacs] 使用ggtags浏览代码
[emacs] 使用ggtags浏览代码 // */ // ]]> [emacs] 使用ggtags浏览代码 Table of Contents 1 相关的连接 2 global简介 2.1 ...
- Emacs golang 配置
在配置前需要下载用到的包: godoc godef gocode oracle 在下载包之前需要设置好环境变量: # Golang export GOROOT=$HOME/go export GOPA ...
- 【程序猿助手】Emacs,最强的编辑器,之间的不
wx_fmt=png" alt="" style="max-width:100%; height:auto!important"> 内容简单 ...
- 【程序员小助手】Emacs,最强编辑器,没有之一
内容简介 1.Emacs简介 2.Emacs三个平台的安装与配置 3.自动补全插件 4.小编的Emacs配置文件 5.常用快捷方式 6.和版本控制系统的配合(以SVN为例) [程序员小助手]系列 在这 ...
- 使用Emacs:生存篇
使用Emacs:生存篇 vim和Emacs都是很强大的编辑器.所以,入门有一定难度.这里不谈vim,谈Emacs下的生存--第一次使用Emacs时的使用. 1.emacs的安装: 在Fedora下: ...
- Emacs阅读chm文档
.title { text-align: center; margin-bottom: .2em } .subtitle { text-align: center; font-size: medium ...
- 使用Emacs中的org-mode写cnblogs之图片插入
.title { text-align: center; margin-bottom: .2em } .subtitle { text-align: center; font-size: medium ...
- 绝世emacs配置for Ubuntu
反正过不了几天就要退役了,把emacs配置放出来造福(祸害)大众? 浓浓的OIER风格,除了方便打代码就没别的用处(F8并不这样认为?),只可惜windows下的弄丢了,只有Ubuntu下的. F1不 ...
- 存个emacs配置
emacs配置 (global-set-key [f9] 'compile-file) (global-set-key [f10] 'gud-gdb) (global-set-key (kbd &qu ...
随机推荐
- php 过滤emoji表情
function yz_expression() { foreach ($_POST as $key => &$value) { $value = preg_replace_callba ...
- webstrom官方的活动模版介绍
编辑模板变量对话框 文件|设置|生活模板--编辑变量Windows和LinuxWebStorm |偏好|生活模板--编辑变量在OS XCtrl + Alt + S 当你点击对话框打开 编辑变量按钮模板 ...
- html5学习(二)音频audio
音频格式 当前,audio 元素支持三种音频格式: IE 9 Firefox 3.5 Opera 10.5 Chrome 3.0 Safari 3.0 Ogg Vorbis √ √ √ M ...
- POJ 2062 HDU 1528 ZOJ 2223 Card Game Cheater
水题,感觉和田忌赛马差不多 #include<cstdio> #include<cstring> #include<cmath> #include<algor ...
- Golang:测试map是否存在
请看这个url:http://www.du52.com/text.php?id=561 if v, ok := m1["a"]; ok { fmt.Println(v) } els ...
- 安卓srcCompat弄死我了
<ImageView android:layout_width="150dp" android:layout_height="120dp" app:src ...
- wpf 类似TextBlock外观的Button的样式
<Style x:Key="noborderbtnStyle" TargetType="{x:Type Button}"> <Setter P ...
- 【转】linux ls -l的详解
原文:http://blog.csdn.net/sjzs5590/article/details/8254527 以root的家目录为例: 可以看到,用ls -l命令查看某一个目录会得到一个7个字段的 ...
- mysql具体语句示例
建表:(not null ,auto_increment, unique , primary key) create database balfish;use balfish;create table ...
- Jquery树控件ZTree异步加载
异步加载的意思就是: 当点击展开树节点时,才去请求后台action返回点击节点的子节点数据并加载. 这里面主要设计ztree的setting变量的async属性设置: var setting = { ...