Skip to content

Instantly share code, notes, and snippets.

@lumin3000
Created December 8, 2010 14:58
Show Gist options
  • Save lumin3000/733372 to your computer and use it in GitHub Desktop.
Save lumin3000/733372 to your computer and use it in GitHub Desktop.
sjerrys's mini .emacs
;;配置路径
(add-to-list 'load-path "~/.emacs.d")
;;字体
(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.
'(default ((t (:inherit nil :stipple nil :background "black" :foreground "white" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 140 :width normal :foundry "unknown" :family "Monospace")))))
;;光标
(setq-default cursor-type 'bar)
;;摘掉菜单,工具栏和滚动条
;;M-` or F10 菜单唤出热键
(toggle-menu-bar-mode-from-frame)
(toggle-tool-bar-mode-from-frame)
(toggle-scroll-bar -1)
;;开启菜单
(global-set-key (kbd "C-<f10>") 'menu-bar-mode)
;;杂项
;;不显示起始提示信息(包括scratch)
(setq inhibit-startup-message t)
(setq initial-scratch-message nil)
;;视觉响铃
(setq visiable-bell t)
;;高亮选中文本
(setq-default transient-mark-mode t)
;;显示列号
(column-number-mode t)
;;显示当前时间
(display-time)
;;c-z keybind:undo
(global-set-key [(control z)] 'undo)
;;一打开就起用 text 模式
(setq default-major-mode 'text-mode)
;;dired模式中不显示隐藏文件
(setq dired-listing-switches "-l")
;;为文件最后加上换行
(setq require-final-newline t)
;;文件相关
;;对文件不进行备份
(setq-default make-backup-files nil)
;;记录最近查看的文件,ido相关
(recentf-mode 1)
(defun recentf-ido-find-file ()
"Find a recent file using ido."
(interactive)
(let ((file (ido-completing-read "Choose recent file: " recentf-list nil t)))
(when file
(find-file file))))
(global-set-key (kbd "C-x f") 'recentf-ido-find-file)
;;记录上次访问文件的光标位置
(require 'saveplace)
(setq-default save-place t)
;;ido mode
(ido-mode t)
(setq ido-enable-prefix nil
ido-enable-flex-matching t
ido-create-new-buffer 'always
ido-use-filename-at-point 'guess
ido-max-prospects 10)
;;通用编程相关
;;自动提示配对的括号
(show-paren-mode 1)
;;提示文件尾的空行
(set-default 'indicate-empty-lines t)
;;不允许用tab做缩进
(set-default 'indent-tabs-mode nil)
;;快捷开启空格显示模式
(global-set-key (kbd "C-c SPC") 'whitespace-mode)
;;定制编辑区良好缩进
(defun untabify-buffer ()
(interactive)
(untabify (point-min) (point-max)))
(defun indent-buffer ()
(interactive)
(indent-region (point-min) (point-max)))
(defun cleanup-buffer ()
"Perform a bunch of operations on the whitespace content of a buffer."
(interactive)
(indent-buffer)
(untabify-buffer)
(delete-trailing-whitespace))
(global-set-key (kbd "C-c n") 'cleanup-buffer)
;;用正则排列行
(global-set-key (kbd "C-x \\") 'align-regexp)
;;归并到上一行
(global-set-key (kbd "C-x ^") 'join-line)
;;新建下一行并缩进
(defun next-newline ()
(interactive)
(move-end-of-line nil)
(newline-and-indent))
(global-set-key (kbd "C-S-j") 'next-newline)
;;新建上一行并缩进
(defun last-newline ()
(interactive)
(forward-line -1)
(move-end-of-line nil)
(newline-and-indent))
(global-set-key (kbd "C-M-j") 'last-newline)
;;programming
(add-to-list 'load-path "~/.emacs.d/vendor/coffee-mode")
(require 'coffee-mode)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment