Skip to content

Commit 13405ed

Browse files
ozanmakesnotpeter
andauthored
Add emacs keybindings for mark emulation (#22904)
These keybindings extend the already selected text. This allows closer emacs emulation where subsequent movement commands extend / shrink the current selection instead of dismissing it. This is a follow up on - #21927 Release Notes: - Added emacs movement keybindings that extend/shrink the current selection --------- Co-authored-by: Peter Tripp <[email protected]>
1 parent c26553d commit 13405ed

File tree

2 files changed

+118
-4
lines changed

2 files changed

+118
-4
lines changed

assets/keymaps/linux/emacs.json

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"ctrl-x b": "tab_switcher::Toggle", // switch-to-buffer
1616
"alt-g g": "go_to_line::Toggle", // goto-line
1717
"alt-g alt-g": "go_to_line::Toggle", // goto-line
18-
//"ctrl-space": "editor::SetMark",
1918
"ctrl-f": "editor::MoveRight", // forward-char
2019
"ctrl-b": "editor::MoveLeft", // backward-char
2120
"ctrl-n": "editor::MoveDown", // next-line
@@ -52,7 +51,65 @@
5251
"alt->": "editor::MoveToEnd", // end-of-buffer
5352
"ctrl-l": "editor::ScrollCursorCenterTopBottom", // recenter-top-bottom
5453
"ctrl-s": "buffer_search::Deploy", // isearch-forward
55-
"alt-^": "editor::JoinLines" // join-line
54+
"alt-^": "editor::JoinLines", // join-line
55+
"alt-/": "editor::ShowCompletions" // dabbrev-expand
56+
}
57+
},
58+
// Extend selection with movement bindings
59+
{
60+
"context": "Editor && (mode == full) && selection",
61+
"bindings": {
62+
"right": "editor::SelectRight",
63+
"left": "editor::SelectLeft",
64+
"down": "editor::SelectDown",
65+
"up": "editor::SelectUp",
66+
"home": "editor::SelectToBeginningOfLine",
67+
"end": "editor::SelectToEndOfLine",
68+
"alt-left": "editor::SelectToPreviousWordStart",
69+
"alt-right": "editor::SelectToNextWordEnd",
70+
"pagedown": "editor::SelectPageDown",
71+
"pageup": "editor::SelectPageUp",
72+
"ctrl-f": "editor::SelectRight",
73+
"ctrl-b": "editor::SelectLeft",
74+
"ctrl-n": "editor::SelectDown",
75+
"ctrl-p": "editor::SelectUp",
76+
"ctrl-a": "editor::SelectToBeginningOfLine",
77+
"ctrl-e": "editor::SelectToEndOfLine",
78+
"alt-f": "editor::SelectToNextWordEnd",
79+
"alt-b": "editor::SelectToPreviousSubwordStart",
80+
"alt-<": "editor::SelectToBeginning",
81+
"alt->": "editor::SelectToEnd",
82+
"ctrl-space": "editor::Cancel" // clear mark
83+
}
84+
},
85+
// Emacs set-mark-command emulation (ctrl-space + movement bindings)
86+
{
87+
"context": "Editor && (mode == full) && !selection",
88+
"bindings": {
89+
"ctrl-space right": "editor::SelectRight",
90+
"ctrl-space left": "editor::SelectLeft",
91+
"ctrl-space down": "editor::SelectDown",
92+
"ctrl-space up": "editor::SelectUp",
93+
"ctrl-space home": "editor::SelectToBeginningOfLine",
94+
"ctrl-space end": "editor::SelectToEndOfLine",
95+
"ctrl-space alt-left": "editor::SelectToPreviousWordStart",
96+
"ctrl-space alt-right": "editor::SelectToNextWordEnd",
97+
"ctrl-space pagedown": "editor::SelectPageDown",
98+
"ctrl-space pageup": "editor::SelectPageUp",
99+
"ctrl-space ctrl-f": "editor::SelectRight",
100+
"ctrl-space ctrl-b": "editor::SelectLeft",
101+
"ctrl-space ctrl-n": "editor::SelectDown",
102+
"ctrl-space ctrl-p": "editor::SelectUp",
103+
"ctrl-space ctrl-a": "editor::SelectToBeginningOfLine",
104+
"ctrl-space ctrl-e": "editor::SelectToEndOfLine",
105+
"ctrl-space alt-f": "editor::SelectToNextWordEnd",
106+
"ctrl-space alt-b": "editor::SelectToPreviousWordStart",
107+
"ctrl-space alt-<": "editor::SelectToBeginning",
108+
"ctrl-space alt->": "editor::SelectToEnd",
109+
"ctrl-space alt-v": "editor::SelectPageUp",
110+
"ctrl-space ctrl-v": "editor::SelectPageDown",
111+
"ctrl-space alt-{": "editor::SelectToStartOfParagraph",
112+
"ctrl-space alt-}": "editor::SelectToEndOfParagraph"
56113
}
57114
},
58115
{

assets/keymaps/macos/emacs.json

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"ctrl-x b": "tab_switcher::Toggle", // switch-to-buffer
1616
"alt-g g": "go_to_line::Toggle", // goto-line
1717
"alt-g alt-g": "go_to_line::Toggle", // goto-line
18-
//"ctrl-space": "editor::SetMark",
1918
"ctrl-f": "editor::MoveRight", // forward-char
2019
"ctrl-b": "editor::MoveLeft", // backward-char
2120
"ctrl-n": "editor::MoveDown", // next-line
@@ -52,7 +51,65 @@
5251
"alt->": "editor::MoveToEnd", // end-of-buffer
5352
"ctrl-l": "editor::ScrollCursorCenterTopBottom", // recenter-top-bottom
5453
"ctrl-s": "buffer_search::Deploy", // isearch-forward
55-
"alt-^": "editor::JoinLines" // join-line
54+
"alt-^": "editor::JoinLines", // join-line
55+
"alt-/": "editor::ShowCompletions" // dabbrev-expand
56+
}
57+
},
58+
// Extend selection with movement bindings
59+
{
60+
"context": "Editor && (mode == full) && selection",
61+
"bindings": {
62+
"right": "editor::SelectRight",
63+
"left": "editor::SelectLeft",
64+
"down": "editor::SelectDown",
65+
"up": "editor::SelectUp",
66+
"home": "editor::SelectToBeginningOfLine",
67+
"end": "editor::SelectToEndOfLine",
68+
"alt-left": "editor::SelectToPreviousWordStart",
69+
"alt-right": "editor::SelectToNextWordEnd",
70+
"pagedown": "editor::SelectPageDown",
71+
"pageup": "editor::SelectPageUp",
72+
"ctrl-f": "editor::SelectRight",
73+
"ctrl-b": "editor::SelectLeft",
74+
"ctrl-n": "editor::SelectDown",
75+
"ctrl-p": "editor::SelectUp",
76+
"ctrl-a": "editor::SelectToBeginningOfLine",
77+
"ctrl-e": "editor::SelectToEndOfLine",
78+
"alt-f": "editor::SelectToNextWordEnd",
79+
"alt-b": "editor::SelectToPreviousSubwordStart",
80+
"alt-<": "editor::SelectToBeginning",
81+
"alt->": "editor::SelectToEnd",
82+
"ctrl-space": "editor::Cancel" // clear mark
83+
}
84+
},
85+
// Emacs set-mark-command emulation (ctrl-space + movement bindings)
86+
{
87+
"context": "Editor && (mode == full) && !selection",
88+
"bindings": {
89+
"ctrl-space right": "editor::SelectRight",
90+
"ctrl-space left": "editor::SelectLeft",
91+
"ctrl-space down": "editor::SelectDown",
92+
"ctrl-space up": "editor::SelectUp",
93+
"ctrl-space home": "editor::SelectToBeginningOfLine",
94+
"ctrl-space end": "editor::SelectToEndOfLine",
95+
"ctrl-space alt-left": "editor::SelectToPreviousWordStart",
96+
"ctrl-space alt-right": "editor::SelectToNextWordEnd",
97+
"ctrl-space pagedown": "editor::SelectPageDown",
98+
"ctrl-space pageup": "editor::SelectPageUp",
99+
"ctrl-space ctrl-f": "editor::SelectRight",
100+
"ctrl-space ctrl-b": "editor::SelectLeft",
101+
"ctrl-space ctrl-n": "editor::SelectDown",
102+
"ctrl-space ctrl-p": "editor::SelectUp",
103+
"ctrl-space ctrl-a": "editor::SelectToBeginningOfLine",
104+
"ctrl-space ctrl-e": "editor::SelectToEndOfLine",
105+
"ctrl-space alt-f": "editor::SelectToNextWordEnd",
106+
"ctrl-space alt-b": "editor::SelectToPreviousWordStart",
107+
"ctrl-space alt-<": "editor::SelectToBeginning",
108+
"ctrl-space alt->": "editor::SelectToEnd",
109+
"ctrl-space alt-v": "editor::SelectPageUp",
110+
"ctrl-space ctrl-v": "editor::SelectPageDown",
111+
"ctrl-space alt-{": "editor::SelectToStartOfParagraph",
112+
"ctrl-space alt-}": "editor::SelectToEndOfParagraph"
56113
}
57114
},
58115
{

0 commit comments

Comments
 (0)