Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

AutoHotkey script to simulate Emacs keybindings on Windows

License

NotificationsYou must be signed in to change notification settings

oneh/autohotkey_emacs_keymap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MyEmacsKeymap.ahk is an AutoHotkey script to simulate Emacs keybindings on Windows.

This script is made largely based on the scripts provided in the following web sites.

Implemented Keybindings

Buffers and FilesSelect, Delete, Copy & Paste
C-x C-ffind-fileC-SPCset-mark-command
C-x C-ssave-bufferC-x hmark-whole-buffer
C-x C-wwrite-fileC-x C-pmark-page
C-x kkill-bufferC-ddelete-char
C-x C-ckill-emacsC-bdelete-backward-char
Cursor MotionC-kkill-line
C-fforward-charC-wkill-region
C-bbackward-charM-wkill-ring-save
C-nnext-lineC-yyank
C-pprevious-lineSearch
M-fforward-char x 5 [*1]C-sisearch-forward [*2]
M-bbackward-char x 5 [*1]C-risearch-forward [*2]
M-nnext-line x 5 [*1]Undo, Cancel
M-pprevious-line x 5 [*1]C-/undo
C-amove-beginning-of-lineC-x uundo
C-emove-end-of-lineC-gkeyboard-quit
C-vscroll-downOthers
M-vscroll-upC-mnew-line
M-<beginning-of-bufferC-iindent-for-tab-command
M->end-of-bufferC-jnew-line
Input Method SwitchingC-oopen-line
C-x C-jtoggle-input-methodC-ttranspose-chars
C-\toggle-input-method
Microsoft Excel, Google Sheets [*3]
C-c aActivates the selected cell with the cursor at the end (Append) (F2)
C-c iActivates the selected cell with the cursor at the beginning (Insert) (F2 + Home)
C-q prefix: Temporarily disabling Emacs keybindings[*4]
C-q C-a(Select All) [*5]C-q C-n(New Window) [*6]
C-q C-p(Print)
C-M keys: Special keys for administration
C-M-qSuspends or resumes the execution of this script
C-M-zTells whether the implemented keybindings should be enabled or not for the application you are on

*1.M-f andM-b move the cursor 5 times instead of moving through words. WhileM-n andM-p do not exist in Emacs keybindings, they can be a good middle ground whenC-n /C-p are too slow andC-v /M-v are too fast for page scrolling.
*2. Search is not incremental. Backward search is not implemented, either.
*3. Whether the active application is Google Sheets is determined atIfWinActive in them_IsGoogleSheets() function. The condition I set is very rough and it returnstrue whenever I am using FireFox or Google Chrome. You may want to modify the code to set a more suitable condition.
*4. The idea of usingC-q to temporarily turn off the tool is from XKeymacs, another keybinding tool I used to use. I have used XKeymacs for so long that it has become almost a reflex to typeC-q C-p for printing.
*5. Personally I useC-q C-a with Microsoft Paint, whereC-x h andC-x C-p both do not work.
*6. Personally I useC-q C-n with Web browsers.

Usage

Launch AutoHotkey (http://ahkscript.org) and loadMyEmacsKeymap.ahk. If you have a fresh installation of AutoHotkey, follow the steps below.

  1. Create an empty file namedAutoHotkey.ahk in the installation directory and add the following line to the file:
#include%A_ScriptDir%\MyEmacsKeymap.ahk
  1. CopyMyEmacsKeymap.ahk in the same directory

  2. StartAutHotkey.exe

Note: If you run AutoHotkey without specifying a script file, the program will first look forAutoHotkey.ahk in the directory where the AutoHotkey executable resides. The path to this directory is stored in theA_ScriptDir built-in variable, and can be referenced as%A_ScriptDir%.

Refer to the following link for a tutorial on how to use AutoHotkey:

Notes

How to prevent "key slips" when holding down keys

"Key slips" may occur when holding down keys. For example, when holding downC-f, the letterf may slip and appear on its own in the output, or the original Windows keymap gets incorrectly passed and the search box may pop up. These symptoms can be suppressed by lowering the Repeat Rate of the keyboard in Control Panel.

How to prevent certain applications from getting affected by this script

Add theahk_class value of such applications to them_IgnoreList list in them_IsEnabled function. Theahk_class value of each application can be identified using Window Spy (AU3_Spy.exe) that comes with AutoHotkey.

The default ignore list includesEmacs,Vim (GVim), andmintty (Cygwin Terminal).

m_IsEnabled() {global  ;; List of applications to be ignored by this script  ;; (Add applications as needed)  ;; Emacs - NTEmacs  ;; Vim - GVim  ;; mintty - Cygwin  m_IgnoreList := ["Emacs","Vim","mintty"]for index, element in m_IgnoreList  {IfWinActiveahk_class %element%Return0  }

How to suspend and resume the execution of this script

C-M-q works as a toggle switch to suspend and resume the execution of this script. PressingC-M-q is the same as selecting "Suspend Hotkeys" from the right-click menu in the AutoHotkey task bar icon.

Sometimes it may not work as expected...

It is a limitation of this script. The porpuse of this script is just to make Windows a little more comfortable to use, not to perfectly emulate Emacs functionality. Also feel free to modify this script as fits your needs.

About

AutoHotkey script to simulate Emacs keybindings on Windows

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp