Emacs Snippets 🔗

🗓 In kb/snippets/

#emacs

Introduction

Emacs is my main text processor software. I do a lot of things with it: writing this snippet, managing some projects with org-mode and, of course, coding. Emacs is very powerful and the learn curve is sometimes very tough and difficult. But with time you will learn how to use it efficiently.

I found some tips to improve my use of Emacs and I will share them here...

Moving a part of text

You want to select a part of text (a region) and move it to the right or to the left, increasing or removing spaces:

Add line numbers (when coding)

Add this line to ~/.emacs.d/init.el:

(global-display-line-numbers-mode)

Add syntax/word checking

You can use flycheck which supports more than 50 languages.

Under Debian:

apt install elpa-flycheck flycheck-doc

Add this line to ~/.emacs.d/init.el:

(add-hook 'after-init-hook #'global-flycheck-mode)

Then you need to install a checker program. We will take the example of Python3 with Pylint:

apt install python3-pylint-common

Add this line to ~/.emacs.d/init.el:

(setq flycheck-python-pylint-executable "python3")

Open a Python3 file and: Ctrl-C ! v to verify is everything is well configured. Then, you can use:

Read flycheck manual for more information...

Use copy and paste in Wayland/X11 with emacs-nox

emacs-nox (Emacs compiled without X11 support) can't handle X11 commands for accessing X11 clipboard. My main short time solution: use xclip!