emacs auto backup

emacs auto backup (setq backup-directory-alist ‘(("" . “~/backup/emacs/backup”))) (setq-default make-backup-file t) (setq make-backup-file t) (setq make-backup-files t) (setq version-control t) (setq kept-old-versions 2) (setq kept-new-versions 10) (setq delete-old-versions t)

Created 23236-04-23 · Updated 23236-04-23 · 1 min · 29 words · -

emacs 插件安装

emacs 插件安装 #edis .emacs (add-to-list 'load-path "/home/wiloon/.emacs.d/lisp") ;;; use groovy-mode when file ends in .groovy or has #!/bin/groovy at start (autoload 'groovy-mode "groovy-mode" "Groovy editing mode." t) ;;files end with .groovy , open as groovy mode (add-to-list 'auto-mode-alist '(".groovy$" . groovy-mode)) (add-to-list 'interpreter-mode-alist '("groovy" . groovy-mode))

Created 23236-04-23 · Updated 23236-04-23 · 1 min · 46 words · -

emacs 查找替换字符串

emacs 查找替换字符串 M-% (然后会出现Query replace的字样) Query replace:<被替换字符串> Query replace <被替换字符串> with:<替换字符串> Query replacing <被替换字符串> with <替换字符串>: (? for help) **查询替换命令的选项如下: ** y 或者 空格 键 替换搜索到的字符串 n 或者 Del 键 取消替换搜索到的字符串 ^ 回到前一个搜索到的字符串 ! 替换所有没有替换的与模式匹配的字符串 ESC 键 退出本次查询搜索

Created 16166-04-16 · Updated 16166-04-16 · 1 min · 38 words · -

emacs 配置/config

emacs 配置/config 中文环境 之后,在~/.Xresources (如果没有的话,自己建一个) ,加入下面内容: Xft.antialias: 1 Xft.hinting: 1 Xft.hintstyle: hintfull 调用X Window系统中的字体,并且开启抗锯齿。 之后在~/.emacs下面加入 (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(inhibit-startup-screen t)) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. ) ; source: http://steve.yegge.googlepages.com/my-dot-emacs-file (defun rename-file-and-buffer (new-name) "Renames both current buffer and file it's visiting to NEW-NAME." (interactive "sNew name: ") (let ((name (buffer-name)) (filename (buffer-file-name))) (if (not filename) (message "Buffer '%s' is not visiting a file!" name) (if (get-buffer new-name) (message "A buffer named '%s' already exists!" new-name) (progn (rename-file filename new-name 1) (rename-buffer new-name) (set-visited-file-name new-name) (set-buffer-modified-p nil)))))) (setq frame-title-format "emacs@%b") ; Set default window size (setq default-frame-alist \`((height . 35) (width . 123))) ;; Set font ;;设置DejaVu Sans Mono为默认情况下的字体,字号为12号。 ;;然后再设置一个字符集,设置字符集字体为WenQuanYi Micro Hei(文泉驿微米黑),当编码为非拉丁字母时, ;;系统自动会在/etc/fonts/cond.avail中寻找编码,比如汉字,就对应han,泰文就对应thai,等等. (set-default-font "DejaVu Sans Mono-11") (set-fontset-font (frame-parameter nil 'font) 'han '("WenQuanYi Micro Hei")) ;; the following function is to scroll the text one line down while keeping the cursor (defun scroll-down-keep-cursor () (interactive) (scroll-down 3)) ;; set cursor as bar (setq-default cursor-type \`bar) ;; hide tool bar (tool-bar-mode 0) ;; hide menu bar (menu-bar-mode 0) ;; hide scroll bar (scroll-bar-mode 0) ;;enable select to clipboard (setq x-select-enable-clipboard t) ;;允许使用C-z作为命令前缀 (define-prefix-command 'ctl-z-map) (global-set-key (kbd "C-z") 'ctl-z-map) ;;用C-z i快速打开~/.emacs文件。 (defun open-init-file ( ) (interactive) (find-file "~/.emacs")) (global-set-key "\C-zi" 'open-init-file) ;;启用ibuffer支持,增强\*buffer\* (require \`ibuffer) (global-set-key (kbd "C-x C-b") \`ibuffer) ;show line number (global-linum-mode t) ;;auto backup (setq backup-by-copying t ;自动备份 backup-directory-alist '(("." . "~/.saves")) ;自动备份在目录"~/.saves"下 delete-old-versions t ;自动删除旧的备份文件 kept-new-versions 6 ;保留最近的6个备份文件 kept-old-versions 2 ;保留最早的2个备份文件 version-control t) ;多次备份 ;显示光标所在的行号列号 (setq column-number-mode t) http://murphytalk.github.io/posts/2005/03/03/gai-bian-emacschuang-kou-biao-ti-ge-shi/#.WJpliCFNzWU ...

Created 16166-04-16 · Updated 16166-04-16 · 2 min · 319 words · -

vim 宏录制

vim 宏录制 在编辑某个文件的时候,可能会出现需要对某种特定的操作进行许多次的情况,以编辑下面的文件为例: ;=====================================================================================;This is a sample configuration file when upgrading XXX using InstallShield.;Author: ini_always;Date: 8/24/2011;Last modified: 9/20/2011;Note: Install script does NOT verify whether the configuration file is in a "WELL";format, a WRONG format may lead to installation failure.;If more information is needed, please check the document for details.;===================================================================================== 这是一个ini类型的配置文件,可以看到每一行的最前面有一个逗号,现在如果需要将每行前面的逗号去掉,怎么办?在第一行行首按x,然后按j,然后按x…这样重复下去?确实,我最开始也是这样的,但如果这个文件有100行要这样修改呢?或者1000行? 好吧,少废话,进入正题。所谓宏,在vim里面是指某种特定顺序的一系列操作,我们可以录制自己的操作序列,然后重复这个序列多次,以简化某种重复的操作。vim宏有录制和播放的过程,录制就是你教给vim该怎么操作,播放就是vim照着你教的进行自动操作。因此,对于上面的文件处理,首先要进行宏录制: 把光标定位在第一行; 在normal模式下输入qa(当然也可以输入qb, qc, etc,这里的a, b, c是指寄存器名称,vim会把录制好的宏放在这个寄存器中)(PS: 如果不知道什么是vim的寄存器,请自行放狗搜之); 正常情况下, vim的命令行会显示"开始录制"的字样,这时候,把光标定位到第一个字符 (按0或者|) ,再按x删除,按j跳到下一行; normal模式下输入q,结束宏录制。 好了,经过以上步骤,我们定义了一个存储在寄存器a中的宏,它的操作序列是: 0->x->j,也就是跳到行首,删除,跳到下一行。 现在,第一行已经删除了行首的逗号,而且光标也已经在第二行,现在,在normal模式下输入@a,以播放我们刚录制好的存在寄存器a中的宏。于是,第二行行首的逗号也被删除,光标停在了第三行。 这也不简单啊?你肯定会这样想,要删除100行,我还得输入100个@a,我还不如手动删除呢。呵呵,vim早就想到了,输入7@a,好了,剩下的7行全部搞定了。 (PS: 在命令前面加数字,就是代表要执行这个命令多少次) ...

1 min · 71 words · -