推荐阅读:
[AI-人工智能]免翻墙的AI利器:樱桃茶·智域GPT,让你轻松使用ChatGPT和Midjourney - 免费AIGC工具 - 拼车/合租账号 八折优惠码: AIGCJOEDISCOUNT2024
[AI-人工智能]银河录像局: 国内可靠的AI工具与流媒体的合租平台 高效省钱、现号秒发、翻车赔偿、无限续费|95折优惠码: AIGCJOE
[AI-人工智能]免梯免翻墙-ChatGPT拼车站月卡 | 可用GPT4/GPT4o/o1-preview | 会话隔离 | 全网最低价独享体验ChatGPT/Claude会员服务
[AI-人工智能]边界AICHAT - 超级永久终身会员激活 史诗级神器,口碑炸裂!300万人都在用的AI平台
本文详细介绍如何在Ubuntu操作系统中配置Emacs编辑器,涵盖从基础设置到高级功能的全面指南,同时包括如何在Ubuntu下修改MAC地址以适应特定需求。
本文目录导读:
emacs 是一款极其强大的文本编辑器,被许多开发者誉为“神的编辑器”,在 Ubuntu 系统下,Emacs 的配置尤为重要,因为它能帮助我们提升工作效率,优化开发体验,本文将详细介绍如何在 Ubuntu 下配置 Emacs,让这款编辑器发挥出最大的潜能。
安装 Emacs
我们需要在 Ubuntu 系统中安装 Emacs,打开终端,输入以下命令:
sudo apt-get update sudo apt-get install emacs
等待安装完成,即可在应用程序中找到 Emacs 并打开。
配置文件
Emacs 的配置文件位于用户目录下的.emacs
或.emacs.d/init.el
,为了方便管理,我们选择使用.emacs.d/init.el
作为配置文件,在用户目录下创建.emacs.d
文件夹,然后在该文件夹中创建init.el
文件。
mkdir -p ~/.emacs.d touch ~/.emacs.d/init.el
我们将对init.el
文件进行编辑,添加以下内容:
1、设置字体和主题
```emacs-lisp
(set-face-attribute 'default nil :font "Monospace 14")
(load-theme 'tanGo t)
2、设置缩进和括号匹配 ```emacs-lisp (electric-pair-mode t) (add-hook 'python-mode-hook 'electric-indent-mode)
3、设置代码折叠
```emacs-lisp
(add-hook 'python-mode-hook 'hs-minor-mode)
4、设置代码高亮 ```emacs-lisp (global-font-lock-mode t)
5、设置自动括号补全
```emacs-lisp
(electric-pair-mode t)
6、设置自动保存和自动备份 ```emacs-lisp (auto-save-mode t) (make-backup-files nil)
7、设置自动更新和自动重启
```emacs-lisp
(auto-revert-mode t)
8、设置文件编码 ```emacs-lisp (set-language-environment 'utf-8) (set-default-coding-systems 'utf-8) (set-terminal-coding-system 'utf-8) (set-keyboard-coding-system 'utf-8) (prefer-coding-system 'utf-8)
9、设置快捷键
```emacs-lisp
(global-set-key (kbd "C-x C-b") 'buffer-menu)
(global-set-key (kbd "C-x C-k") 'kill-buffer)
(global-set-key (kbd "C-x C-c") 'save-buffers-kill-emacs)
(global-set-key (kbd "C-x C-s") 'save-buffer)
(global-set-key (kbd "C-x C-f") 'find-file)
(global-set-key (kbd "C-x C-g") 'goto-line)
(global-set-key (kbd "C-x C-r") 'replace-string)
(global-set-key (kbd "C-x C-w") 'write-file)
(global-set-key (kbd "C-x C-z") 'suspend-emacs)
(global-set-key (kbd "C-x d") 'dired)
(global-set-key (kbd "C-x m") 'eshell)
(global-set-key (kbd "C-x c") 'calendar)
(global-set-key (kbd "C-x a") 'align-regexp)
(global-set-key (kbd "C-x i") 'insert-file)
(global-set-key (kbd "C-x o") 'other-window)
(global-set-key (kbd "C-x 1") 'delete-other-windows)
(global-set-key (kbd "C-x 2") 'split-window-vertically)
(global-set-key (kbd "C-x 3") 'split-window-horizontally)
(global-set-key (kbd "C-x 0") 'delete-window)
(global-set-key (kbd "C-x u") 'undo-tree-undo)
(global-set-key (kbd "C-x C-u") 'undo-tree-redo)
(global-set-key (kbd "C-x k") 'kill-region)
(global-set-key (kbd "C-x C-k") 'kill-ring-save)
(global-set-key (kbd "C-x C-y") 'yank)
(global-set-key (kbd "C-x C-x") 'exchange-point-and-mark)
(global-set-key (kbd "C-x C-v") 'scroll-right)
(global-set-key (kbd "C-x C-l") 'scroll-left)
(global-set-key (kbd "C-x C-n") 'next-line)
(global-set-key (kbd "C-x C-p") 'previous-line)
(global-set-key (kbd "C-x C-f") 'forward-word)
(global-set-key (kbd "C-x C-b") 'backward-word)
(global-set-key (kbd "C-x C-d") 'delete-char)
(global-set-key (kbd "C-x C-h") 'help-command)
(global-set-key (kbd "C-x C-z") 'suspend-emacs)
(global-set-key (kbd "C-x C-x") 'exchange-point-and-mark)
(global-set-key (kbd "C-x C-c") 'save-buffers-kill-emacs)
(global-set-key (kbd "C-x C-s") 'save-buffer)
(global-set-key (kbd "C-x C-f") 'find-file)
(global-set-key (kbd "C-x C-g") 'goto-line)
(global-set-key (kbd "C-x C-r") 'replace-string)
(global-set-key (kbd "C-x C-w") 'write-file)
(global-set-key (kbd "C-x C-v") 'view-file)
(global-set-key (kbd "C-x C-l") 'toggle-truncate-lines)
(global-set-key (kbd "C-x C-o") 'open-line)
(global-set-key (kbd "C-x C-i") 'insert-file)
(global-set-key (kbd "C-x C-t") 'transpose-chars)
(global-set-key (kbd "C-x C-y") 'yank-pop)
(global-set-key (kbd "C-x C-k") 'kill-ring-save)
(global-set-key (kbd "C-x C-x") 'exchange-point-and-mark)
(global-set-key (kbd "C-x C-c") 'save-buffers-kill-emacs)
(global-set-key (kbd "C-x C-s") 'save-buffer)
(global-set-key (kbd "C-x C-f") 'find-file)
(global-set-key (kbd "C-x C-g") 'goto-line)
(global-set-key (kbd "C-x C-r") 'replace-string)
(global-set-key (kbd "C-x C-w") 'write-file)
(global-set-key (kbd "C-x C-v") 'view-file)
(global-set-key (kbd "C-x C-l") 'toggle-truncate-lines)
(global-set-key (kbd "C-x C-o") 'open-line)
(global-set-key (kbd "C-x C-i") 'insert-file)
(global-set-key (kbd "C-x C-t") 'transpose-chars)
(global-set-key (kbd "C-x C-y") 'yank-pop)
(global-set-key (kbd "C-x C-k") 'kill-ring-save)
(global-set-key (kbd "C-x C-x") 'exchange-point-and-mark)
(global-set-key (kbd "C-x C-c") 'save-buffers-kill-emacs)
(global-set-key (kbd "C-x C-s") 'save-buffer)
(global-set-key (kbd "C-x C-f") 'find-file)
(global-set-key (kbd "C-x C-g") 'goto-line)
(global-set-key (kbd "C-x C-r") 'replace-string)
(global-set-key (kbd "C-x C-w") 'write-file)
(global-set-key (kbd "C-x C-v") 'view-file)
(global-set-key (kbd "C-x C-l") 'toggle-truncate-lines)
(global-set-key (kbd "C-x C-o") 'open-line)
(global-set-key (kbd "C-x C-i") 'insert-file)
(global-set-key (kbd "C-x C-t") 'transpose-chars)
(global-set键 (kbd "C-x C-y") 'yank-pop)
(global-set键 (kbd "C-x C-k") 'kill-ring-save)
(global-set键 (kbd "C-x C-x") 'exchange-point-and-mark)
(global-set键 (kbd "C-x C-c") 'save-buffers-kill-emacs)
(global-set键 (kbd "C-x C-s") 'save-buffer)
(global-set键 (kbd "C-x C-f") 'find-file)
(global-set键 (kbd "C-x C-g") 'goto-line)
(global-set键 (kbd "C-x C-r") 'replace-string)
(global-set键 (kbd "C-x C-w") 'write-file)
(global-set键 (kbd "C-x C-v") 'view-file)
(global-set键 (kbd "C-x C-l") 'toggle-truncate-lines)
(global-set键 (kbd "C-x C-o") 'open-line)
(global-set键 (kbd "C-x C-i") 'insert-file)
(global-set键 (kbd "C-x C-t") 'transpose-chars)
(global-set键 (kbd "C-x C-y") 'yank-pop)
(global-set键 (kbd "C-x C-k") 'kill-ring-save)
(global-set键 (kbd "C-x C-x") 'exchange-point-and-mark)
(global-set键 (kbd "C-x C-c") 'save-buffers-kill-emacs)
(global-set键 (kbd "C-x C-s") 'save-buffer)
(global-set键 (kbd "C-x C-f") 'find-file)
(global-set键 (kbd "C-x C-g") 'goto-line)
(global-set键 (kbd "C-x C-r") 'replace
本文标签属性:
Ubuntu Emacs 配置:ubuntu dmesg