Skip to content

Insert operators with surrounding spaces smartly. (Refactored and successor of smart-operator.el).

Notifications You must be signed in to change notification settings

xwl/electric-spacing

Repository files navigation

Electric spacing mode

An emacs minor-mode to automatically add spacing around operators.

For example typing

a=10*5+2

results in

a = 10 * 5 + 2

Setup

The simplest way to install electric-spacing-mode is via package.el.

To temporarily enable electric-spacing-mode simply call electric-spacing-mode. To permenantly enable it for a major mode simply add it to the relevant mode hook. For example for python-mode add the following to your config[1]:

(add-hook 'python-mode-hook #'electric-spacing-mode)

Note that electric-spacing-mode is not a global minor mode, and so must be enabled separately for each major mode.

Major Mode Specific Tunings

To fine tune the spacing for specific operators in FOO-mode, you can just define mode specific function to override. For example, to redefine operator spacing for '-' in text-mode:

(defun electric-spacing-text-mode-- ()
  (electric-spacing-insert "-" 'middle))

[1] For emacs versions < 24 you may need to define a wrapper function to enable the mode unconditionally.

About

Insert operators with surrounding spaces smartly. (Refactored and successor of smart-operator.el).

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published