Giter VIP home page Giter VIP logo

universal-emacs-keybindings's Introduction

Universal Emacs Keybindings

Use the Emacs keybindings you love across all applications for mac and windows.

example image

Features

  • Ctrl-Space can be used to preform Emacs style text selection outside of Emacs
  • Supports Emacs prefix keys such as Ctrl-xs (save)
  • Allows you to specify app specific overrides (Google Chrome)
  • Apps with native Emacs keybindings are left alone
  • OS specific keybindings are left alone (alt+tab, ctrl+c, cmd+c, etc)

Installation for Mac

  1. Download and install Hammerspoon
  2. Copy emacs_hammerspoon.lua to ~/.hammerspoon/init.lua
  3. Launch Hammerspoon

Installation for Windows

  1. Download and Install AutoHotkey
  2. Launch emacs_autohotkey.ahk (notice the green system tray icon)
  3. Add emacs_authotkey.ahk to your Windows startup script. Checkout this guide.

Customizing the keybindings

Both windows and mac use the global keys to configure keybindings.

Namespaces

Namespaces are used inside keys to send different keys to different apps.

globalEmacs sends Emacs like keybindings to all non-Emacs apps globalOverride overrides all app including Emacs appName app specific overrides

The keys variable

The keys variable is structured using the following pattern:

  1. Namespace
  2. Source modifier keys such as ctrl, alt, alt+shift, ...
  3. Source non-modifier key such as a,b,c, space, /, ...
  4. Destination Modifiers and non-modifiers keys
  5. A boolean indicating if the keybinding will maintain a text selection
  6. Run a macro to run instead of a translating a keys

Windows keys syntax example

"globalEmacs" : { "ctrl" { "a": ["{Home}", True, ""] } }
  1. globalEmacs means this keybinding is for all non-Emacs apps
  2. Translate the modifier key Ctrl
  3. Translate the key a
  4. Destination keys are Home
  5. True tells the script to maintain the current text selection if currently selecting
  6. No macro to run for this keybinding

Mac keys syntax example

['globalEmacs'] = { ["ctrl"] = { ['delete'] = {nil, nil, false, 'macroBackwardsKillWord'} } }
  1. globalEmacs means this keybinding is for all non-Emacs apps
  2. Translate the modifier key Ctrl
  3. Translate the key delete (or Backspace)
  4. No destination modifier or key
  5. false tells the script to cancel a text selection if already started
  6. run the macro macroBackwardsKillWord (which runs multiple keys presses)

White-list apps that already have Emacs keybindings

In Hammerspoon add name of your app to the following list:

local appsWithNativeEmacsKeybindings = { 'emacs', 'terminal' }

In Autohotkey add the name of your app's exec to the following list:

global appsWithNativeEmacsKeybindings = ["emacs.exe", "conemu64.exe"]

Blog post

I wrote a blog post laying out my reasons for developing these scripts.

Special thanks to the following scripts for inspiration:

universal-emacs-keybindings's People

Contributors

justintanner avatar chenyixin-2 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.