feat: emacs - auto save on focus-out

This commit is contained in:
Ryan Yin
2024-01-03 00:54:59 +08:00
parent 26e5a3d12e
commit c9102ead4f
3 changed files with 39 additions and 20 deletions
+27 -19
View File
@@ -1,11 +1,11 @@
# Emacs Editor # Emacs Editor
- Framework: <https://github.com/doomemacs/doomemacs> - Framework: <https://github.com/doomemacs/doomemacs>
- key bindings: <https://github.com/doomemacs/doomemacs/blob/master/modules/config/default/%2Bevil-bindings.el> - key bindings: <https://github.com/doomemacs/doomemacs/blob/master/modules/config/default/%2Bevil-bindings.el>
- Chinese(rime) support: <https://github.com/DogLooksGood/emacs-rime> - Chinese(rime) support: <https://github.com/DogLooksGood/emacs-rime>
- modal editing: - modal editing:
- <https://github.com/emacs-evil/evil>: evil mode, enabled by default in doom-emacs. - <https://github.com/emacs-evil/evil>: evil mode, enabled by default in doom-emacs.
- <https://github.com/meow-edit/meow> - <https://github.com/meow-edit/meow>
## Install or Update ## Install or Update
@@ -14,6 +14,7 @@ After deploying this nix flake, run the following command to install or update e
```bash ```bash
doom sync doom sync
``` ```
## Terminal Related ## Terminal Related
zellij provides a more powerful and stable terminal experience, so here is zellij's terminal shortcuts I use frequently now: zellij provides a more powerful and stable terminal experience, so here is zellij's terminal shortcuts I use frequently now:
@@ -23,6 +24,7 @@ zellij provides a more powerful and stable terminal experience, so here is zelli
| Floating Terminal | `Ctrl + <p> + <w>` | | Floating Terminal | `Ctrl + <p> + <w>` |
| Horizontal Split Terminal | `Ctrl + <p> + <d>` | | Horizontal Split Terminal | `Ctrl + <p> + <d>` |
| Vertical Split Terminal | `Ctrl + <p> + <n>` | | Vertical Split Terminal | `Ctrl + <p> + <n>` |
| Open file tree sidebar | `SPC + o + p` |
## Visual Modes ## Visual Modes
@@ -59,28 +61,34 @@ The same as neovim/vim:
## Splitting and Buffers ## Splitting and Buffers
| Action | Shortcut | | Action | Shortcut |
| --------------------- | ------------- | | --------------------- | ----------------- |
| Next Buffer (Tab) | `]b` | | Next Buffer (Tab) | `]b` |
| Previous Buffer (Tab) | `[b` | | Previous Buffer (Tab) | `[b` |
| Save all buffers(Tab) | `<Space> + b + S` | | Save all buffers(Tab) | `<Space> + b + S` |
## Editing and Formatting ## Editing and Formatting
| Action | Shortcut | | Action | Shortcut |
| ----------------------------------------------------- | -------------- | | ---------------------------------------- | ------------------- |
| Format Document | `<Space> + cf` | | Format Document | `<Space> + cf` |
| Code Actions | `<Space> + ca` | | Code Actions | `<Space> + ca` |
| Rename | `<Space> + cr` | | Rename | `<Space> + cr` |
| Opening LSP symbols | `<Space> + cS` | | Opening LSP symbols | `<Space> + cS` |
| Comment Line(support multiple lines) | `<Space> + /` | | Comment Line(support multiple lines) | `<Space> + /` |
| Open filepath/URL at cursor | `gf` | | Open filepath/URL at cursor | `gf` |
| Find files by keyword in path | `<Space> + <Space>` | | Find files by keyword in path | `<Space> + <Space>` |
| Grep string in files (vertico + ripgrep) | `<Space> + sd` | | Grep string in files (vertico + ripgrep) | `<Space> + sd` |
## Text Manipulation
| Action | |
| ---------------------------------- | --- |
| Join Selection of Lines With Space | `J` |
## Search & replace ## Search & replace
``` bash ```bash
SPC s p foo C-; E C-c C-p :%s/foo/bar/g RET Z Z SPC s p foo C-; E C-c C-p :%s/foo/bar/g RET Z Z
``` ```
@@ -83,3 +83,11 @@
("TAB" . 'copilot-accept-completion) ("TAB" . 'copilot-accept-completion)
("C-TAB" . 'copilot-accept-completion-by-word) ("C-TAB" . 'copilot-accept-completion-by-word)
("C-<tab>" . 'copilot-accept-completion-by-word))) ("C-<tab>" . 'copilot-accept-completion-by-word)))
(use-package super-save
:ensure t
:config
(super-save-mode +1)
(setq super-save-auto-save-when-idle t)
(setq super-save-all-buffers t)
(setq super-save-delete-trailing-whitespace t))
@@ -8,6 +8,9 @@
(package! copilot (package! copilot
:recipe (:host github :repo "copilot-emacs/copilot.el" :files ("*.el" "dist"))) :recipe (:host github :repo "copilot-emacs/copilot.el" :files ("*.el" "dist")))
(package! super-save
:recipe (:host github :repo "bbatsov/super-save" :files ("*.el" "dist")))
;; To install SOME-PACKAGE from MELPA, ELPA or emacsmirror: ;; To install SOME-PACKAGE from MELPA, ELPA or emacsmirror:
;; (package! some-package) ;; (package! some-package)