环境

使用 Windows Terminal + WSL2

WSL2 Arch Linux

配置

Windows Terminal

Windows Terminal 中打开设置,选择打开 JSON 文件,在 schemes 中添加配色方案

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"schemes":
[
{
"background": "#0D1117",
"black": "#484F58",
"blue": "#58A6FF",
"brightBlack": "#6E7681",
"brightBlue": "#79C0FF",
"brightCyan": "#56D4DD",
"brightGreen": "#56D364",
"brightPurple": "#D2A8FF",
"brightRed": "#FFA198",
"brightWhite": "#FFFFFF",
"brightYellow": "#E3B341",
"cursorColor": "#2F81F7",
"cyan": "#39C5CF",
"foreground": "#E6EDF3",
"green": "#3FB950",
"name": "GitHub-Dark-Default",
"purple": "#BC8CFF",
"red": "#FF7B72",
"selectionBackground": "#E6EDF3",
"white": "#B1BAC4",
"yellow": "#D29922"
}
],

  • 在 archlinux 的配置中选择 外观 选项卡
    • 配色方案选择 GitHub-Dark-Default
    • 字体选择 FiraCode Nerd Font
    • 背景不透明度 86%,选择启用亚克力材料
  • 在 archlinux 的配置中选择 高级 选项卡
    • 铃声通知样式取消勾选声音,选择闪烁窗口和闪烁任务栏
  • 安装win32yank.exe放入C:\Winodws\System32里

Arch Linux

archlinux 需要下载一些软件包

下载yay参考

注意下载后最好对pacman和yay进行换源,否则速度巨慢

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
sudo nano /etc/locale.gen
# 找到#en_US.UTF-8 UTF-8解除注释
sudo locale-gen
sudo pacman -Sy emacs-nox
sudo pacman -Sy clang rust-analyzer nvm ripgrep bear

source /usr/share/nvm/init-nvm.sh
nvm list-remote
nvm install v20.19.4
nvm use v20.19.4
# npm换源
npm i -g pyright bash-language-server

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rm ~/.cargo/bin/rust-analyzer
ln -s /usr/bin/rust-analyzer ~/.cargo/bin/rust-analyzer

cargo install --git https://github.com/bergercookie/asm-lsp asm-lsp

# 创建配置文件,也可以用默认配置
asm-lsp gen-config
# 将FiraCode Nerd Font的ttf文件拷贝到 ~/.local/share/fonts/
git clone https://github.com/sebastiencs/icons-in-terminal.git
./install.sh
# then Follow the instructions to edit ~/.config/fontconfig/conf.d/30-icons.conf

sudo pacman -S exa
echo 'alias ll="ls -alF"' >> ~/.bashrc
echo 'alias ls="exa --icons"' >> ~/.bashrc
source ~/.bashrc

Emacs 配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
;;不显示menu-bar
(menu-bar-mode -1)
;;显示行号
(global-display-line-numbers-mode t)
;;在ModeLine显示列号
(add-hook 'prog-mode-hook 'column-number-mode)
;;代码的折叠
(add-hook 'prog-mode-hook 'hs-minor-mode)
;; 自动重载更改的文件
(global-auto-revert-mode 1)
;;开启可视化换行,自动折行
(global-visual-line-mode 1)
;; 括号匹配
(electric-pair-mode 1)

;; 中文显示
(set-language-environment "utf-8")
(set-buffer-file-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-clipboard-coding-system 'utf-8)
(modify-coding-system-alist 'process "*" 'utf-8)
(prefer-coding-system 'utf-8)
(setq-default pathname-coding-system 'utf-8)
(setq default-process-coding-system '(utf-8 . utf-8)
locale-coding-system 'utf-8
file-name-coding-system 'utf-8
default-buffer-file-coding-system 'utf-8
slime-net-coding-system 'utf-8-unix
)


(setenv "LC_CTYPE" "UTF-8")
(setenv "LC_ALL" "en_US.UTF-8")
(setenv "LANG" "en_US.UTF-8")

(setq find-file-encoding 'auto)
(setq-default coding-system-for-read 'utf-8)
(setq-default coding-system-for-write 'utf-8)

;; 基本设置
(defalias 'yes-or-no-p 'y-or-n-p)

(setq-default window-combination-resize t ;; 新窗口平均其他左右窗口
x-stretch-cursor t ;; 将光标拉伸到字形宽度
indent-tabs-mode nil ;; 不使用 TAB 字符,使用空格
tab-width 2 ;; tab 宽度设为 2 空格
)

(setq ring-bell-function 'ignore
initial-scratch-message nil
inhibit-startup-message t
auto-save-file-name-transforms '((".*" "~/.emacs.d/data/backup/" t)) ;; Write auto-save files to a separate directory
backup-directory-alist '(("." . "~/.emacs.d/data/backup/")) ;; Write backup files to a separate directory
create-lockfiles nil ;; Disable lockfiles
scroll-conservatively 10000 ;;防止页面滚动时跳动
scroll-step 1 ;; 当光标移动到边缘时,窗口每次只滚动一行
undo-limit 80000000 ;; 提升撤销限制
display-time-default-load-average nil ;; 不显示系统负载
electric-indent-mode 1 ;; 自动缩进
)


;; 时间显示设置
;; (setq display-time-24hr-format t ;; 时间使用24小时制
;; display-time-day-and-date t ;; 时间显示包括日期和具体时间
;; display-time-interval 10 ;; 时间的变化频率
;; display-time-format "%Y-%m-%d %A %H:%M") ;; 显示完整日期
;; ;; 启用时间显示设置,在minibuffer上面的那个杠上
;; (display-time-mode 1)
;; ;; 立即强制刷新一次时间
;; (display-time-update)

;; 使用 Fira Code Nerd Font 字体
(set-face-attribute 'default nil
:font "FiraCode Nerd Font"
:height 120) ;; 120=12pt,可根据需求调整


;; wsl与windos共享剪切版
(defun my/clipboard-to-windows (text &optional push)
(let ((process-connection-type nil))
(with-temp-buffer
(insert text)
(call-process-region (point-min) (point-max) "win32yank.exe" nil nil nil "-i"))))

(defun my/clipboard-from-windows ()
(string-trim-right
(with-output-to-string
(call-process "win32yank.exe" nil standard-output nil "-o"))))

(setq interprogram-cut-function 'my/clipboard-to-windows)
(setq interprogram-paste-function 'my/clipboard-from-windows)



;;设置镜像源
;; (setq package-archives
;; '(("melpa" . "https://melpa.org/packages/")
;; ("gnu" . "https://elpa.gnu.org/packages/")))
(setq package-archives '(("gnu" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/gnu/")
("nongnu" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/nongnu/")
("melpa" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/")))

(use-package package
:config
(unless (bound-and-true-p package--initialized)
(package-initialize)))

(setq use-package-always-ensure t)

;;doom主题
(use-package doom-themes
:ensure t
:init
:config
(setq doom-themes-enable-bold t ; if nil, bold is universally disabled
doom-themes-enable-italic t) ; if nil, italics is universally disable
;; 加载主题(例如 doom-one)
(load-theme 'doom-tomorrow-night t)
;; 启用可选配置
;; 高亮当前行
(doom-themes-visual-bell-config)
;; 改善 Org-mode 颜色
(doom-themes-org-config))

(defun my/kill-scratch-buffer ()
"在 Emacs 启动时关闭 *scratch* buffer."
(when (get-buffer "*scratch*")
(kill-buffer "*scratch*")))
(add-hook 'emacs-startup-hook #'my/kill-scratch-buffer)

;;在执行操作(如撤销、替换、复制)时提供视觉反馈。
(use-package volatile-highlights
:ensure t
:init
(volatile-highlights-mode t)) ;; 启用 volatile-highlights

;; tab栏显示buffer
(use-package centaur-tabs
:ensure t
:demand
:init
:config
(defun centaur-tabs-hide-tab (x)
"自定义隐藏规则:隐藏特殊或无文件 buffer,但保留 vterm buffer."
(let ((name (format "%s" x)))
(or
;; 隐藏无文件 buffer,但保留 *vterm* buffer
(and (not (buffer-file-name x)))
;; 专用窗口
(window-dedicated-p (selected-window))
;; 临时 buffer
(string-prefix-p "*" name)
(string-prefix-p " " name)
;; Magit 非文件 buffer
(and (string-prefix-p "magit" name)
(not (file-name-extension name))))))

(setq centaur-tabs-style "bar"
centaur-tabs-set-bar 'over
centaur-tabs-enable-key-bindings nil
centaur-tabs-set-icons t
centaur-tabs-icon-type 'nerd-icons
centaur-tabs-set-close-button nil
centaur-tabs-show-new-tab-button nil
centaur-tabs-cycle-scope 'tabs)
;;启用插件
(centaur-tabs-mode t)
:bind
("C-<left>" . centaur-tabs-backward)
("C-<right>" . centaur-tabs-forward))

;; a light that follows your cursor
(use-package beacon
:ensure t
:config
(beacon-mode 1))

;; modeline主题
(use-package doom-modeline
:ensure t
:after nyan-mode
:custom
(doom-modeline-buffer-file-name-style 'truncate-all)
:init (doom-modeline-mode 1))

;;显示进度条
(use-package nyan-mode
:ensure t
:init
(nyan-mode 1))

;;文件导航栏
(use-package neotree
:ensure t
:bind (("<f8>" . neotree-toggle))
:config
(setq neo-theme 'nerd-icons)
(setq neo-smart-open t) ;; 打开时自动跳到当前文件路径
(setq neo-show-hidden-files t);; 显示隐藏文件
)
;; neotree buffer 中强制截断长行
(add-hook 'neo-after-create-hook
(lambda (_)
;; 不换行,禁用 visual-line(你全局开了的话)
(visual-line-mode -1)
(setq-local truncate-lines t)

;; 用 “…” 代替右侧的 $ 截断标记
(let ((tbl (or buffer-display-table (make-display-table))))
(set-display-table-slot tbl 'truncation (make-glyph-code ?…))
(setq-local buffer-display-table tbl))))
;; 允许 neotree 窗口宽度可调整
(with-eval-after-load 'neotree
(setq neo-window-fixed-size nil))

(use-package nerd-icons
:custom
;; The Nerd Font you want to use in GUI
;; "Symbols Nerd Font Mono" is the default and is recommended
;; but you can use any other Nerd Font if you want
(nerd-icons-font-family "FiraCode Nerd Font")
)

;; use-package with package.el:
(use-package dashboard
:ensure t
:config
(dashboard-setup-startup-hook)
;; recentf mode 必须开启
(recentf-mode 1)
;; 快捷键
(setq dashboard-navigation-cycle t
dashboard-show-shortcuts nil
dashboard-set-footer nil
dashboard-center-content t;; Content is not centered by default. To center, set
dashboard-vertically-center-content t;; vertically center content
dashboard-items '((recents . 5) ;; 显示的 widget: 最近文件、书签、项目、agenda
(projects . 5)
(agenda . 5))
dashboard-projects-backend 'projectile ;; 设置项目列表使用 Projectile
dashboard-display-icons-p t ;; 开启显示图标
dashboard-icon-type 'nerd-icons ;; 使用 nerd-icons
dashboard-set-file-icons t ;; 文件图标
dashboard-set-heading-icons nil)) ;; 标题图标显示


;; enhancement for amx
(use-package amx
:ensure t
:init (amx-mode))

;; 保存最近打开的buffers到disk
(use-package perspective
:custom
(persp-mode-prefix-key (kbd "C-c M-p")) ; pick your own prefix key here
(persp-state-default-file "~/.emacs.d/persp-state.el") ;; 默认保存位置
:init
(persp-mode))
;; 退出 Emacs 时自动保存 session
(add-hook 'kill-emacs-hook #'persp-state-save)


;;预览要跳转的行
(use-package goto-line-preview :ensure t
:bind (("M-g g" . goto-line-preview)))


;;代码整行上移下移
(use-package move-dup
:bind (("C-M-p" . move-dup-move-lines-up)
;; ("C-M-p" . move-dup-duplicate-up)
("C-M-n" . move-dup-move-lines-down)
;; ("C-M-n" . move-dup-duplicate-down)
))

(use-package exec-path-from-shell
:ensure t
:config
(when (memq window-system '(mac ns x))
(exec-path-from-shell-initialize)))

;; 保证在编程模式下缩进是主要行为
(add-hook 'prog-mode-hook
(lambda ()
(setq-local indent-line-function #'indent-relative)))
;; Git工具
(use-package magit
:ensure t
:defer t
:bind (("C-x g" . magit-log-all))
)

(use-package markdown-mode
:ensure t
:mode ("\\.md\\'" . markdown-mode)
:init (setq markdown-command "pandoc"))


;; 语法解析
(use-package tree-sitter
:when (and (fboundp 'treesit-available-p)
(treesit-available-p))
:config (setq treesit-font-lock-level 4)
:init
(setq treesit-language-source-alist
'((bash . ("https://github.com/tree-sitter/tree-sitter-bash"))
(c . ("https://github.com/tree-sitter/tree-sitter-c"))
(cpp . ("https://github.com/tree-sitter/tree-sitter-cpp"))
(python . ("https://github.com/tree-sitter/tree-sitter-python"))
(rust . ("https://github.com/tree-sitter/tree-sitter-rust"))
(toml . ("https://github.com/tree-sitter/tree-sitter-toml"))
(elisp . ("https://github.com/Wilfred/tree-sitter-elisp"))
(cmake . ("https://github.com/uyha/tree-sitter-cmake"))
(dockerfile . ("https://github.com/camdencheek/tree-sitter-dockerfile"))
(make . ("https://github.com/alemuller/tree-sitter-make"))
(yaml . ("https://github.com/ikatyang/tree-sitter-yaml"))
(json . ("https://github.com/tree-sitter/tree-sitter-json"))
(java . ("https://github.com/tree-sitter/tree-sitter-java.git"))
;;(markdown . ("https://github.com/MDeiml/tree-sitter-markdown" nil "tree-sitter-markdown/src"))
))

;;没有内置<languate>-mode的需要添加
(add-to-list 'auto-mode-alist '("\\.y[a]?ml\\'" . yaml-ts-mode))
(add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-ts-mode))
(add-to-list 'auto-mode-alist '("\\(?:Dockerfile\\(?:\\..*\\)?\\|\\.[Dd]ockerfile\\)\\'" . dockerfile-mode))
)

;; 安装 tree-sitter 语法解析器(仅 Emacs 29+)
(dolist (lang '(bash c cpp python rust toml elisp cmake dockerfile make yaml json java))
(unless (treesit-language-available-p lang)
(treesit-install-language-grammar lang)))

;; 优先使用 Tree-sitter mode
(setq major-mode-remap-alist
'((bash-mode . bash-ts-mode)
(c-mode . c-ts-mode)
(c++-mode . c++-ts-mode)
(python-mode . python-ts-mode)
(rust-mode . rust-ts-mode)
(conf-toml-mode . toml-ts-mode)
(elisp-mode . elisp-ts-mode)
(cmake-mode . cmake-ts-mode)
(dockerfile-mode . dockerfile-ts-mode)
(json-mode . json-ts-mode)
(java-mode . java-ts-mode)
(yaml-mode . yaml-ts-mode)
(makefile-mode . makefile-ts-mode)
))

;; lsp语言服务器配置
(require 'eglot)

(setq eglot-server-programs
'(((c++-mode c-mode c++-ts-mode c-ts-mode) . ("clangd"))
((rust-mode rust-ts-mode) . ("rust-analyzer"))
((asm-mode nasm-mode) . ("asm-lsp"))
((python-mode python-ts-mode) . ("pyright-langserver" "--stdio"))
;;((java-mode java-ts-mode) . ("jdtls"))
((bash-mode bash-ts-mode sh-mode sh-ts-mode) . ("bash-language-server" "start"))
;;((markdown-mode) . ("marksman"))
;;((latex-mode LaTeX-mode) . ("texlab"))
))
;;关闭lsp自动格式化
(setq eglot-ignored-server-capabilities '(:documentFormattingProvider))
;;自动打开eglot
(dolist (hook '(c-mode-hook c-ts-mode-hook
c++-mode-hook c++-ts-mode-hook
rust-mode-hook rust-ts-mode-hook
asm-mode-hook nasm-mode-hook
python-mode-hook python-ts-mode-hook
;; java-mode-hook java-ts-mode-hook
;; markdown-mode-hook
bash-mode-hook bash-ts-mode-hook
sh-mode-hook sh-ts-mode-hook
;; latex-mode-hook LaTeX-mode-hook
))
(add-hook hook 'eglot-ensure))

(global-set-key (kbd "M-n") #'flymake-goto-next-error)
(global-set-key (kbd "M-p") #'flymake-goto-prev-error)

;; eglot快捷键
(global-set-key (kbd "M-,") 'xref-find-definitions) ;; 跳转到定义
(global-set-key (kbd "M-.") 'xref-pop-marker-stack) ;; 跳回
(global-set-key (kbd "M-?") 'xref-find-references) ;; 查找引用


;; 显示诊断信息(自动 hover 显示错误、警告等)
(setq eldoc-idle-delay 0.2) ;; 光标停留 0.2 秒后显示提示


;; comment
(defun my-cpp-line-comments ()
"Use // comments instead of /* */ in C/C++."
(setq-local comment-start "// "
comment-end ""
comment-start-skip "//+\\s-*"))

(dolist (hook '(c-mode-hook c++-mode-hook c-ts-mode-hook c++-ts-mode-hook
rust-mode-hook rust-ts-mode-hook python-mode-hook python-ts-mode-hook java-mode-hook java-ts-mode-hook))
(add-hook hook #'my-cpp-line-comments))

;; 自动补全
(use-package company :ensure t :defer t
:hook (after-init . global-company-mode))
;; company-quickhelp 配置
(use-package company-quickhelp
:ensure t
:after company
:config
;; 启用 company-quickhelp
(company-quickhelp-mode 1)
;; 设置弹出延迟(秒),比如 0.5 秒
(setq company-quickhelp-delay 0.5))

(use-package flx
:ensure t)
(use-package company-fuzzy
:ensure t
:after company
:hook (company-mode . company-fuzzy-mode)
:init
(setq company-fuzzy-sorting-backend 'flx ;; 选择模糊匹配算法
company-fuzzy-reset-selection t ;; 选中候选时重置到第一个
company-fuzzy-prefix-on-top nil ;; 是否把 prefix 值置顶
company-fuzzy-trigger-symbols '("." "->" "<" "\"" "'" "@") ;; 触发符号
company-fuzzy-show-annotation t ;; 显示注释
company-fuzzy-passthrough-backends '(company-capf)) ;; 排除部分 backend
:config
;; 全局启用
(global-company-fuzzy-mode 1))


;; 格式化
(use-package format-all
:ensure t
:commands format-all-mode
:hook (prog-mode . format-all-mode)
:config
;; 不在保存时自动格式化
(remove-hook 'before-save-hook 'format-all-buffer t)
(setq-default format-all-formatters
'(("C" (clang-format))
("C++" (clang-format))
("rust" (rustfmt))
)))

(global-set-key (kbd "C-x f") 'format-all-buffer)

;; 代码模板
;; YASnippet 配置
(use-package yasnippet
:ensure t
:hook (prog-mode . yas-minor-mode) ;; 只在编程模式启用
:config
;; 启动时加载所有 snippet
(yas-reload-all)
;; 设置 snippet 目录
(setq yas-snippet-dirs
'("~/.emacs.d/snippets" ;; 个人片段
"~/.emacs.d/elpa/yasnippet-snippets-*/snippets"))) ;; 社区合集

(use-package yasnippet-snippets
:ensure t
:after yasnippet)


;; which-key 显示键绑定提示
(use-package which-key
:ensure t
:config
(which-key-mode))
;; 窗格切换
(use-package ace-window
:ensure t
:bind (("M-o" . ace-window)))
;; 窗格移动
(use-package buffer-move
:ensure t
:bind (("C-c <up>" . buf-move-up)
("C-c <down>" . buf-move-down)
("C-c <left>" . buf-move-left)
("C-c <right>" . buf-move-right)))
;; 智能按键C-a C-c k
(use-package crux
:bind (("C-a" . 'crux-move-beginning-of-line)
("C-c k" . 'crux-smart-kill-line)))
;; 项目识别,通过创建.projectile文件识别为一个项目
(use-package projectile
:ensure t
:init
(projectile-mode +1)
:bind-keymap
("C-c p" . projectile-command-map)
:config
(setq projectile-project-search-path '("~/repository"))
(setq projectile-completion-system 'auto) ;; 或 ivy / helm / default
(use-package rg
:ensure t))


;; 快捷键定义必须放在后面否则容易被其他插件覆盖
;;enhancement for help
(use-package helpful
:ensure t
:bind
(("C-h f" . helpful-callable) ;; 替换 describe-function
("C-h v" . helpful-variable) ;; 替换 describe-variable
("C-h k" . helpful-key) ;; 替换 describe-key
("C-h x" . helpful-command) ;; 替换 describe-command
("C-c C-d" . helpful-at-point) ;; 光标下符号
("C-h F" . helpful-function))) ;; 查看函数,不含宏

(defun kill-other-buffers ()
"Kill all buffers except the current one."
(interactive)
(mapc (lambda (buf)
(unless (eq buf (current-buffer))
(kill-buffer buf)))
(buffer-list)))

;; 关闭其他buffers
(global-set-key (kbd "C-c k") #'kill-other-buffers)
;;撤销
(global-set-key (kbd "C-/") 'undo-only)
;;撤销刚才的撤销
(global-set-key (kbd "C-?") 'undo-redo)
;; 快捷键绑定:使用调整窗口大小
(global-set-key (kbd "M-<up>") 'enlarge-window)
(global-set-key (kbd "M-<down>") 'shrink-window)
(global-set-key (kbd "M-<left>") 'shrink-window-horizontally)
(global-set-key (kbd "M-<right>") 'enlarge-window-horizontally)


(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.
'(package-selected-packages nil))
(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.
)

预览

preview

快捷键配置总览

快捷键 功能描述 来源配置
C-/ 撤销(undo-only) 手动绑定
C-? 重做(undo-redo) 手动绑定
M- 增大当前窗口高度 手动绑定
M- 减小当前窗口高度 手动绑定
M- 减小当前窗口宽度 手动绑定
M- 增大当前窗口宽度 手动绑定
C- 切换到前一个 Tab(Centaur Tabs) centaur-tabs
C- 切换到下一个 Tab centaur-tabs
M-g g 预览跳转到指定行(goto-line-preview) goto-line-preview
M-C-p 将当前行上移 move-dup
M-C-n 将当前行下移 move-dup
M-p 下一个错误 flymake
M-n 上一个错误 flymake
f8 打开/关闭文件树侧边栏(neotree) neotree
C-x g 查看当前 Git 仓库的所有提交 magit
C-x f 格式化当前 buffer(clang-format / rustfmt) format-all
M-, 跳转到定义(xref-find-definitions,需 LSP 支持) 手动绑定
M-. 跳回上一个位置(xref-pop-marker-stack) 手动绑定
M-? 查找引用(xref-find-references,需 LSP 支持) 手动绑定
M-o 在多个窗口间切换焦点 ace-window
C-c 当前 buffer 上移到另一个窗口 buffer-move
C-c 当前 buffer 下移到另一个窗口 buffer-move
C-c 当前 buffer 左移到另一个窗口 buffer-move
C-c 当前 buffer 右移到另一个窗口 buffer-move
C-a 智能移动光标到行首(再次按可回到代码开始处) crux
C-c k 智能删除一行(不会破坏缩进) crux
C-c p Projectile 项目命令前缀 projectile
C-x SPC 矩形选择模式,可以选择某些列 内置
  • 全局查找
    M-X projectile-ripgrep
  • neotree
    • M-x neotree-create-node 创建文件
    • M-x neotree-delete-node 删除文件
    • M-x neotree-rename-node 重命名文件
  • M-x persp-state-load 打开上次打开的 buffer
  • M-x recenter 把当前行放在窗口中间

编程设置

有 makefile 的 project

1
2
make clean
bear -- make