forked from butscher/WikidPad
-
Notifications
You must be signed in to change notification settings - Fork 0
EmacsStyleKeybindings
Christian Ziemski edited this page Mar 6, 2016
·
5 revisions
This plugin is used to enable Emacs-style keyboard shortcuts for editing.
You may need disable mnemonics to use all the Alt shortcuts.
Add following line in ~/.gtkrc
file
gtk-enable-mnemonics = 0
- Ctrl+N: Move cursor vertically down one line.
- Ctrl+P: Move cursor vertically up one line.
- Ctrl+E: Move point to end of current line.
- Ctrl+A: Move point to beginning of current line.
- Ctrl+F: Move point right one character.
- Ctrl+B: Move point left one character.
- Alt+F: Move point forward one word.
- Alt+B: Move point backward one word.
- Ctrl+V: Scroll up.
- Alt+V: Scroll down.
- Alt+>: Move point to the end of the buffer.
- Alt+<: Move point to the beginning of the buffer.
- Ctrl+D: Delete.
- Ctrl+H: Backspace.
- Alt+D: Delete words forward.
- Alt+SPACE: Delete words backward.
- Ctrl+W: Cut.
- Alt+W: Copy.
- Ctrl+K: Kill the rest of the current line.
- Ctrl+Y: Paste.
WIKIDPAD_PLUGIN = (("[[MenuFunctions]]", 1), )
def describeMenuItems(pwiki):
return ((next_line,
"Emacs Style Keybindings|Next Line\tCtrl+N",
"Next Line"),
(previous_line,
"Emacs Style Keybindings|Prev Line\tCtrl+P",
"Prev Line"),
(move_end_of_line,
"Emacs Style Keybindings|Line End\tCtrl+E",
"Line end"),
(move_beginning_of_line,
"Emacs Style Keybindings|Line Start\tCtrl+A",
"Line start"),
(forward_char,
"Emacs Style Keybindings|Forward Char\tCtrl+F",
"forward char"),
(backward_char,
"Emacs Style Keybindings|Backward Char\tCtrl+B",
"backward char"),
(forward_word,
"Emacs Style Keybindings|Forward Word\tAlt+F",
"forward word"),
(backward_word,
"Emacs Style Keybindings|Backward Word\tAlt+B",
"backward word"),
(scroll_down,
"Emacs Style Keybindings|Scroll Down\tCtrl+V",
"scroll down"),
(scroll_up,
"Emacs Style Keybindings|Scroll Up\tAlt+v",
"scroll up"),
(end_of_buffer,
"Emacs Style Keybindings|End of Buffer\tAlt+>",
"end of buffer"),
(begining_of_buffer,
"Emacs Style Keybindings|Beginning of Buffer\tAlt+<",
"beginning of buffer"),
(delete_char,
"Emacs Style Keybindings|Delete Char\tCtrl+D",
"delete char"),
(backward_delete_char,
"Emacs Style Keybindings|Backward Delete Char\tCtrl+H",
"backward delete char"),
(kill_word,
"Emacs Style Keybindings|Kill Word\tAlt+D",
"kill word"),
(backward_kill_word,
"Emacs Style Keybindings|Backward Kill Word\tAlt+SPACE",
"backward kill word"),
(kill_region,
"Emacs Style Keybindings|Kill Region\tCtrl+W",
"kill region"),
(kill_ring_save,
"Emacs Style Keybindings|Kill Ring Save\tAlt+W",
"kill ring save"),
(kill_line,
"Emacs Style Keybindings|Kill Line\tCtrl+k",
"kill line"),
(yank,
"Emacs Style Keybindings|Yank\tCtrl+Y",
"yank"),
)
def next_line(pwiki, evt):
editor = pwiki.getActiveEditor()
editor.[[LineDown]]()
def previous_line(pwiki, evt):
editor = pwiki.getActiveEditor()
editor.[[LineUp]]()
def move_end_of_line(pwiki, evt):
editor = pwiki.getActiveEditor()
editor.[[LineEnd]]()
def move_beginning_of_line(pwiki, evt):
editor = pwiki.getActiveEditor()
editor.Home()
def forward_char(pwiki, evt):
editor = pwiki.getActiveEditor()
editor.[[CharRight]]()
def backward_char(pwiki, evt):
editor = pwiki.getActiveEditor()
editor.[[CharLeft]]()
def forward_word(pwiki, evt):
editor = pwiki.getActiveEditor()
editor.[[WordRight]]()
def backward_word(pwiki, evt):
editor = pwiki.getActiveEditor()
editor.[[WordLeft]]()
def scroll_down(pwiki, evt):
editor = pwiki.getActiveEditor()
editor.[[PageDown]]()
def scroll_up(pwiki, evt):
editor = pwiki.getActiveEditor()
editor.[[PageUp]]()
def end_of_buffer(pwiki, evt):
editor = pwiki.getActiveEditor()
editor.[[DocumentEnd]]()
def begining_of_buffer(pwiki, evt):
editor = pwiki.getActiveEditor()
editor.[[DocumentStart]]()
def delete_char(pwiki, evt):
editor = pwiki.getActiveEditor()
editor.[[CharRight]]()
editor.[[DeleteBack]]()
def backward_delete_char(pwiki, evt):
editor = pwiki.getActiveEditor()
editor.[[DeleteBack]]()
def kill_word(pwiki, evt):
editor = pwiki.getActiveEditor()
editor.[[DelWordRight]]()
def backward_kill_word(pwiki, evt):
editor = pwiki.getActiveEditor()
editor.[[DelWordLeft]]()
def kill_region(pwiki, evt):
editor = pwiki.getActiveEditor()
editor.Cut()
def kill_ring_save(pwiki, evt):
editor = pwiki.getActiveEditor()
editor.Copy()
def kill_line(pwiki, evt):
editor = pwiki.getActiveEditor()
cur_pos = editor.[[GetCurrentPos]]()
line_num = editor.[[LineFromPosition]](cur_pos)
end_of_line = editor.[[GetLineEndPosition]](line_num)
beginning_of_line = editor.[[PositionFromLine]](line_num)
if beginning_of_line == end_of_line:
editor.[[LineDelete]]()
elif cur_pos == end_of_line:
editor.[[DelWordRight]]()
else:
editor.[[SetSelectionStart]](cur_pos)
editor.[[SetSelectionEnd]](end_of_line)
editor.Cut()
def yank(pwiki, evt):
editor = pwiki.getActiveEditor()
if editor.[[CanPaste]]():
editor.Paste()