Format rust code in emacs using rustfmt
Emacs Lisp
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README.md
rustfmt.el

README.md

rustfmt.el - OBSOLETE

MELPA

This package has been merged into rust-mode. Please use that instead.

Format rust code in emacs using rustfmt.

Install

Ensure you are using MELPA:

(require 'package)
(add-to-list 'package-archives
             '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)

Then install the "rustfmt" package:

  • M-x package-list-packages
  • Find the "rustfmt" and install with I

Usage

Run M-x rustfmt-format-buffer to format the current buffer.

For convenience, you may bind it to a key, such as:

(define-key rust-mode-map (kbd "C-c C-f") #'rustfmt-format-buffer)

Alternatively, run rustfmt before saving rust buffers:

(add-hook 'rust-mode-hook #'rustfmt-enable-on-save)