emacs配置文件中比较好用的函数
来源:互联网 发布:myotee脸萌软件 编辑:程序博客网 时间:2024/05/18 02:51
(声明:这些函数非本人原创,是本人从各处收集的,后期还会更新)
1.在当前行之前,之后插入新行(类似与vim在normal模式下的a和o键)
出处(http://whattheemacsd.com/)
;;C-return 在当前行上新开一行;;C-S-return 在当前行下新开一行(defun open-line-below () (interactive) (end-of-line) (newline) (indent-for-tab-command))(defun open-line-above () (interactive) (beginning-of-line) (newline) (forward-line -1) (indent-for-tab-command))(global-set-key (kbd "<C-return>") 'open-line-below)(global-set-key (kbd "<C-S-return>") 'open-line-above)
C即ctrl键,S即shift键盘;
使用elisp语言定义了两个函数,open-line-below和open-line-above.
open-line-below是在当前行之下插入新行,open-line-above实在当前行之上插入新行
将这两个函数分别映射到了<C-return>和<C-S-return>两个快捷键上.
2.emacs全屏
出处(Deepin linux emacs中的配置);;; fullscreen.el --- Full screen;; Filename: fullscreen.el;; Description: Full screen;; Author: Andy Stewart <lazycat.manatee@gmail.com>;; Maintainer: Andy Stewart <lazycat.manatee@gmail.com>;; Copyright (C) 2009, Andy Stewart, all rights reserved.;; Created: 2009-02-11 21:05:32;; Version: 0.1;; Last-Updated: 2009-02-11 21:05:32;; By: Andy Stewart;; URL: http://www.emacswiki.org/emacs/download/fullscreen.el;; Keywords: fullscreen;; Compatibility: GNU Emacs 23.0.60.1;;;; Features that might be required by this library:;;;;;;;;; This file is NOT part of GNU Emacs;;; License;;;; This program is free software; you can redistribute it and/or modify;; it under the terms of the GNU General Public License as published by;; the Free Software Foundation; either version 3, or (at your option);; any later version.;; This program is distributed in the hope that it will be useful,;; but WITHOUT ANY WARRANTY; without even the implied warranty of;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the;; GNU General Public License for more details.;; You should have received a copy of the GNU General Public License;; along with this program; see the file COPYING. If not, write to;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth;; Floor, Boston, MA 02110-1301, USA.;;; Commentary:;;;; Full screen.;;;; Below are commands you can use:;;;; `fullscreen' Full screen.;; `fullscreen-toggle' Toggle full screen status.;;;;; Installation:;;;; Put fullscreen.el to your load-path.;; The load-path is usually ~/elisp/.;; It's set in your ~/.emacs like this:;; (add-to-list 'load-path (expand-file-name "~/elisp"));;;; And the following to your ~/.emacs startup file.;;;; (require 'fullscreen);;;; No need more.;;; Customize:;;;;;;;; All of the above can customize by:;; M-x customize-group RET fullscreen RET;;;;; Change log:;;;; 2009/02/11;; * First released.;;;;; Acknowledgements:;;;;;;;;; TODO;;;;;;;;; Require;;; Code:(defun fullscreen () "Fullscreen." (interactive) (x-send-client-message nil 0 nil "_NET_WM_STATE" 32 ;; if first parameter is '1', can't toggle fullscreen status '(1 "_NET_WM_STATE_FULLSCREEN" 0)))(defun fullscreen-toggle () "Toggle fullscreen status." (interactive) (x-send-client-message nil 0 nil "_NET_WM_STATE" 32 ;; if first parameter is '2', can toggle fullscreen status '(2 "_NET_WM_STATE_FULLSCREEN" 0)))(provide 'fullscreen);;; fullscreen.el ends here将上面这段代码复制下来,保存为fullscreen.el,在.emacs中加入fullscreen.el的路径,在.emacs加入以下代码:
(require 'fullscreen)(global-set-key [f11] 'fullscreen-toggle)绑定到了快捷键F11上,按一次最大化,再按一次又恢复了,很方便
效果图:
3.重命名当前缓冲区
;;快捷键 C-x C-r重命名当前缓冲区(defun rename-current-buffer-file () "Renames current buffer and file it is visiting." (interactive) (let ((name (buffer-name)) (filename (buffer-file-name))) (if (not (and filename (file-exists-p filename))) (error "Buffer '%s' is not visiting a file!" name) (let ((new-name (read-file-name "New name: " filename))) (if (get-buffer new-name) (error "A buffer named '%s' already exists!" new-name) (rename-file filename new-name 1) (rename-buffer new-name) (set-visited-file-name new-name) (set-buffer-modified-p nil) (message "File '%s' successfully renamed to '%s'" name (file-name-nondirectory new-name)))))))(global-set-key (kbd "C-x C-r") 'rename-current-buffer-file)快捷键绑定到了ctrl-x ctrl-r上
- emacs配置文件中比较好用的函数
- emacs一些比较好用的功能配置
- 一份比较好用的vim配置文件
- 关于emacs比较好的站点
- Emacs中使用purcell大师的配置文件
- 在Gentoo上为Emacs装上了ecb,及找到一个比较好用的.emacs设置
- vim 配置文件,经过修改,比较好用的版本
- 看过的觉得比较好的一些emacs使用资料
- 一个比较好用的C函数
- c/c++写的比较好的读写配置文件的函数或者类
- Android中比较好用的框架
- 我的emacs配置文件
- emacs的配置文件
- 我的 Emacs 配置文件
- 我的 .emacs配置文件
- emacs配置文件的基础知识
- 我的emacs配置文件
- emacs配置文件的基础知识
- (专栏)链接
- 巧妙运用ViewStub写出类似Tab选项卡(想怎么写tab就怎么写,横着写竖着写随你)
- ubuntu data backup and recovery
- JQuery验证工具类
- HTML基础(三):图解CSS的padding,margin,border属性
- emacs配置文件中比较好用的函数
- curl_setopt使用方法
- C++ 函数类型
- 简单地基于cxf框架的webservice完整开发示例
- Physical Database Limits
- 国外24个jQuery搜索插件
- croostool-ng 交叉编译过程
- 使用静态成员函数 统计学生成绩
- eclipse生成jar包