Skip to content

Commit

Permalink
Add keybindings: M-f M-b C-< C->
Browse files Browse the repository at this point in the history
  • Loading branch information
JerryChu committed Dec 18, 2020
1 parent d828ebf commit e6cc092
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 3 deletions.
48 changes: 45 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# emacs.ahk
This tiny script allows you to use the emacs-like key bindings on Windows, which is written in AutoHotkey (AHK) language. The maintainer has used this script since 2007 and has verified that it works effectively for various kinds of applications.
Allows you to use emacs-like key bindings on Windows environment.

This script is written in AutoHotkey (AHK) and has been maintained since Sep 21, 2007.

## Supported keybindings
<table>
<tr>
<th>Keybinding</th>
<th>Emacs Lisp Function</th>
<th>Function(Emacs Lisp)</th>
</tr>
<tr>
<td>C-Space</td>
Expand All @@ -28,6 +30,10 @@ This tiny script allows you to use the emacs-like key bindings on Windows, which
<td>kill-emacs</td>
</tr>
<tr>
<td>C-x h</td>
<td>select-all</td>
</tr>
<tr>
<td>C-d</td>
<td>delete-char</td>
</tr>
Expand Down Expand Up @@ -108,19 +114,55 @@ This tiny script allows you to use the emacs-like key bindings on Windows, which
<td>backward-char</td>
</tr>
<tr>
<td>M-f</td>
<td>forward-word</td>
</tr>
<tr>
<td>M-b</td>
<td>backward-word</td>
</tr>
<tr>
<td>C-v</td>
<td>scroll-down</td>
</tr>
<tr>
<td>M-v</td>
<td>scroll-up</td>
</tr>
<tr>
<td>M-<</td>
<td>goto home</td>
</tr>
<tr>
<td>M-></td>
<td>goto end</td>
</tr>


<tr>
<td>W-c</td>
<td>copy</td>
</tr>
<tr>
<td>W-x</td>
<td>cut</td>
</tr>
<tr>
<td>W-v</td>
<td>paste</td>
</tr>
<tr>
<td>W-a</td>
<td>select-all</td>
</tr>
</table>


## Some webpages that introduced this script
## Webpages introducing this script
* [AutoHotkeyでemacs風キーバインド - torutkの日記](http://d.hatena.ne.jp/torutk/20101009/p2)
* [オダろぐ : Emacs>AutoHotKey の Emacsモードを使うことにした](http://blog.livedoor.jp/odaxsen/archives/1546840.html)
* [AutoHotkey &laquo; sea side she side](http://www.a10i.jp/?tag=autohotkey)
* [NTEmacs @ ウィキ - Windows の操作を emacs のキーバインドで行う設定 (AutoHotKey版)](http://www49.atwiki.jp/ntemacs/pages/20.html)
* Customized by 2cher
* [WindowsでEmacs風キーバインド - Usipedia](http://usi3.com/index.php?title=Windows%E3%81%A7Emacs%E9%A2%A8%E3%82%AD%E3%83%BC%E3%83%90%E3%82%A4%E3%83%B3%E3%83%89)
* My web site
83 changes: 83 additions & 0 deletions emacs.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ quit()
{
Send {ESC}
global is_pre_spc = 0
global is_pre_x = 0
Return
}
newline()
Expand Down Expand Up @@ -157,6 +158,13 @@ kill_emacs()
Return
}

select_all()
{
Send ^a
global is_pre_x = 0
Return
}

move_beginning_of_line()
{
global
Expand All @@ -175,6 +183,26 @@ move_end_of_line()
Send {END}
Return
}

move_to_beginning()
{
global
if is_pre_spc
Send +^{HOME}
Else
Send ^{HOME}
Return
}
move_to_end()
{
global
if is_pre_spc
Send +^{END}
Else
Send ^{END}
Return
}

previous_line()
{
global
Expand Down Expand Up @@ -211,6 +239,26 @@ backward_char()
Send {Left}
Return
}

forward_word()
{
global
if is_pre_spc
Send +^{Right}
Else
Send ^{Right}
Return
}
backward_word()
{
global
if is_pre_spc
Send +^{Left}
Else
Send ^{Left}
Return
}

scroll_up()
{
global
Expand Down Expand Up @@ -418,3 +466,38 @@ Return
scroll_up()
Return

!f::
If is_target()
Send %A_ThisHotkey%
Else
forward_word()
Return
!b::
If is_target()
Send %A_ThisHotkey%
Else
backward_word()
Return
!<::
If is_target()
Send %A_ThisHotkey%
Else
move_to_beginning()
Return
!>::
If is_target()
Send %A_ThisHotkey%
Else
move_to_end()
Return
h::
If is_target()
Send %A_ThisHotkey%
Else
{
if is_pre_x
select_all()
Else
Send %A_ThisHotkey%
}
Return

0 comments on commit e6cc092

Please sign in to comment.