I showed you my source code, pls respond
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
3.1 KiB

  1. #+TITLE: Evil
  2. #+AUTHOR: Christopher James Hayward
  3. #+EMAIL: chris@chrishayward.xyz
  4. #+PROPERTY: header-args:emacs-lisp :tangle evil.el :comments org
  5. #+PROPERTY: header-args :results silent :eval no-export :comments org
  6. #+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil
  7. #+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
  8. Transform Emacs into Vim.
  9. * Config
  10. Emacs has some strange default keybindings, which given the age of the project, is not surprising. To overcome this nearly show-stopping hurdle, we transform Emacs into Vim with ~evil~[fn:1], the Extensible VI Layer for Emacs.
  11. #+begin_src emacs-lisp
  12. (use-package evil
  13. :custom (evil-want-integration t) ;; Required for `evil-collection'.
  14. (evil-want-keybinding nil) ;; Same as above
  15. :config (evil-mode +1))
  16. #+end_src
  17. ** Improvements
  18. While covering substantial ground towards the goal, the default keybindings implemented in ~evil~[fn:1] alone are lacking compared to what you would expect from Vim. There's a community curated package ~evil-collection~[fn:2] that does a much better job implementing the proper keybindings.
  19. #+begin_src emacs-lisp
  20. (use-package evil-collection
  21. :after evil
  22. :config (evil-collection-init))
  23. #+end_src
  24. ** Surround text
  25. Quickly and efficiently surround text with ~evil-surround~[fn:3]. Highlight blocks of text with function definitions, quotations, or any symbol you can input from your keyboard.
  26. #+begin_src emacs-lisp
  27. (use-package evil-surround
  28. :after evil
  29. :config (global-evil-surround-mode 1))
  30. #+end_src
  31. ** Line numbering
  32. Relative line numbers are important when using VI emulation keys. You can prefix commands with a number, allowing you to perform that action that number of times. Useful when navigating around pages that are hundreds, or even thousands of lines long.
  33. #+begin_example
  34. 5:
  35. 4:
  36. 3:
  37. 2:
  38. 1:
  39. 156: << CURRENT LINE >>
  40. 1:
  41. 2:
  42. 3:
  43. 4:
  44. 5:
  45. #+end_example
  46. This behaviour is implemented with ~linum-relative~[fn:4], hooking into the ~display-line-number-mode~ as the backend for good performance in the GUI or TTY.
  47. #+begin_src emacs-lisp
  48. (use-package linum-relative
  49. :commands (linum-relative-global-mode)
  50. :custom (linum-delay t)
  51. (linum-relative-backend 'display-line-numbers-mode))
  52. #+end_src
  53. ** Toggle comments
  54. Toggle comments in a language agnostic manner with ~evil-nerd-commenter~[fn:5]. Add a custom binding to =M-;= to mimmic the behaviour in other popular Emacs configuration frameworks. What is =M-?= Called the *Meta* key in Emacs, it typically refers to =Alt=.
  55. #+begin_src emacs-lisp
  56. (use-package evil-nerd-commenter
  57. :after evil
  58. :bind ("M-;" . evilnc-comment-or-uncomment-lines))
  59. #+end_src
  60. * Shortcuts
  61. Toggle relative line numbers with =SPC t l=.
  62. #+begin_src emacs-lisp
  63. (dotfiles/leader
  64. "tl" '(linum-relative-global-mode :which-key "Lines"))
  65. #+end_src
  66. * Footnotes
  67. [fn:1] https://github.com/emacs-evil/evil-mode
  68. [fn:2] https://github.com/emacs-evil/evil-collection
  69. [fn:3] https://github.com/emacs-evil/evil-surround
  70. [fn:4] https://github.com/emacsmirror/linum-relative
  71. [fn:5] https://github.com/redguardtoo/evil-nerd-commenter