Skip to content

Lem Manual for Users

Sasanidas edited this page May 30, 2023 · 32 revisions

The documentation is in progress. You can find a first list of available keys and commands in default-keybindings.md.

Lem Manual for Users

Lem has Emacs-like keybindings, as well as a vi emulation (M-x vi-mode).

So, to open a file, press C-x C-f (you get the file selection dialog shown above). To save it, it's C-x C-s. To save many buffers at once, C-x s.

To switch to the REPL: C-c C-z.

To compile and load a buffer: C-c C-k. To compile a function: C-c C-c.

To switch windows (aka splits of a screen): C-x o ('o' letter) and M-o. To make a window fullscreen: C-x 1. To split it vertically: C-x 3 and horizontally: C-x 2. To make the current window disappear: C-x 0 (zero).

To switch buffers: C-x b.

To run an interactive command: M-x (alt-x).

To evaluate some Lisp code: M-:.

To show the context menu: Shift-F10.

See this Emacs & Slime cheatsheet to find more: https://lispcookbook.github.io/cl-cookbook/emacs-ide.html#appendix

Switching buffers

Use C-x b (aka M-x list-buffers). But don't stop here, it's a rich command.

You are presented a "modale" window. Type some text to start narrowing the buffers list matching your entry.

You can also use Space to select/deselect entries, then use a right click to choose an action to apply on the selected buffers. Default actions are to kill the selected buffers, or to save them.

vi and emacs modes

Use M-x vi-mode and M-x emacs-mode.

Describe keys

To know what function is bound to a key binding, use M-x describe-key (C-x ?).

Describe available bindings

To see the currently available key bindings, use M-x describe-bindings.

See also describe-mode, to understand in which mode the editor is in the current buffer.

grep

M-x grep

this presents the results in a two-panes window. You can edit lines in the results buffer, changes are reflected immediately on the files, and updated on the right side. You can use search and replace M-x query-replace in the results buffer.

multiple cursors

Use M-C (Alt and capital c), `M-x add-cursors-to-next-line) to add a cursor to the next line.

Working with a language's Language Server Protocol (LSP)

For Go, if you have gopls, it should work without doing anything.

Otherwise, configurations are required.

Supported languages

Elixir

elixir-mode (preliminary work merged on 30th, May 2023) adds:

  • syntax highlighting
  • preliminary LSP support
  • M-x run-elixir command
  • M-x elixir-eval-region

For more information: https://github.com/lem-project/lem/pull/647

Defining a new color theme (Monokai example)

(if none of the 100 available in Lem 2.0 don't satisfy you)

;; thanks https://gist.github.com/jason-chandler/6332e3fd753fa87e3b1cd13582df5862
(define-color-theme "monokai" ()
  (:foreground "#eeeeee")
  (:background "#262626")
  (cursor :foreground "#262626" :background "#eeeeee")
  (syntax-warning-attribute :foreground "#87005f" :background "#262626")
  (syntax-string-attribute :foreground "#d7d787" :background "#262626")
  (syntax-comment-attribute :foreground "#666666" :background "#262626")
  (syntax-keyword-attribute :foreground "#5fd7ff" :background "#262626")
  (syntax-constant-attribute :foreground "#5fd7ff" :background "#262626")
  (syntax-function-name-attribute :foreground "#afd700" :background "#262626")
  (syntax-variable-attribute :foreground nil :background "#262626")
  (syntax-type-attribute :foreground nil :background "#262626")
  (syntax-builtin-attribute :foreground nil :background "#262626"))

(load-theme "monokai")

Example users' init files