-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #219 from Lindenk/keybindings
Added basic support for rebinding keys.
- Loading branch information
Showing
11 changed files
with
510 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
|
||
// An enum of all bindable actions in Vim | ||
// TODO: Split off commands into normal, insert, and visual catagories | ||
export enum Command { | ||
// Enter insert mode | ||
InsertAtCursor = 1, | ||
InsertAtLineBegin, | ||
InsertAfterCursor, | ||
InsertAtLineEnd, | ||
InsertNewLineBelow, | ||
InsertNewLineAbove, | ||
|
||
// Movement | ||
MoveUp, | ||
MoveDown, | ||
MoveLeft, | ||
MoveRight, | ||
|
||
MoveLineBegin, | ||
MoveLineEnd, | ||
MoveWordBegin, | ||
MoveWordEnd, | ||
MoveFullWordBegin, | ||
MoveFullWordEnd, | ||
MoveLastWord, | ||
MoveLastFullWord, | ||
MoveLastWordEnd, | ||
MoveLastFullWordEnd, | ||
|
||
// MoveHalfPageUp, | ||
// MoveHalfPageDown, | ||
MoveFullPageUp, | ||
MoveFullPageDown, | ||
// MoveFirstLine, | ||
// MoveLastLine, | ||
|
||
MoveParagraphBegin, | ||
MoveParagraphEnd, | ||
|
||
MoveNonBlank, | ||
MoveNonBlankFirst, | ||
MoveNonBlankLast, | ||
MoveMatchingBracket, | ||
|
||
// Find | ||
Find, | ||
|
||
// Text Modification | ||
Undo, | ||
Redo, | ||
Copy, | ||
Paste, | ||
|
||
ChangeWord, | ||
ChangeFullWord, | ||
ChangeCurrentWord, | ||
ChangeCurrentWordToNext, | ||
ChangeToLineEnd, | ||
|
||
DeleteLine, | ||
DeleteToNextWord, | ||
DeleteToFullNextWord, | ||
DeleteToWordEnd, | ||
DeleteToFullWordEnd, | ||
DeleteToWordBegin, | ||
DeleteToFullWordBegin, | ||
DeleteToLineEnd, | ||
|
||
DeleteChar, | ||
DeleteLastChar, | ||
|
||
Indent, | ||
Outdent, | ||
|
||
// Misc | ||
EnterVisualMode, | ||
EnterCommand, | ||
ExitMessages, | ||
} | ||
|
||
export function newDefaultNormalKeymap() : {[key: string]: Command} { | ||
return { | ||
"h": Command.MoveLeft, | ||
"j": Command.MoveDown, | ||
"k": Command.MoveUp, | ||
"l": Command.MoveRight, | ||
"0": Command.MoveLineBegin, | ||
"$": Command.MoveLineEnd, | ||
|
||
"^": Command.MoveNonBlank, | ||
"gg": Command.MoveNonBlankFirst, | ||
"G": Command.MoveNonBlankLast, | ||
|
||
"w": Command.MoveWordBegin, | ||
"W": Command.MoveFullWordBegin, | ||
"e": Command.MoveWordEnd, | ||
"E": Command.MoveLastFullWordEnd, | ||
"ge": Command.MoveLastWordEnd, | ||
"gE": Command.MoveLastFullWordEnd, | ||
"b": Command.MoveLastWord, | ||
"B": Command.MoveLastFullWord, | ||
|
||
"{": Command.MoveParagraphBegin, | ||
"}": Command.MoveParagraphEnd, | ||
"%": Command.MoveMatchingBracket, | ||
|
||
">>": Command.Indent, | ||
"<<": Command.Outdent, | ||
|
||
"u": Command.Undo, | ||
"ctrl+r": Command.Redo, | ||
"y": Command.Copy, | ||
"p": Command.Paste, | ||
|
||
"cw": Command.ChangeWord, | ||
"cW": Command.ChangeFullWord, | ||
"ciw": Command.ChangeCurrentWord, | ||
"caw": Command.ChangeCurrentWordToNext, | ||
"C": Command.ChangeToLineEnd, | ||
|
||
"dd": Command.DeleteLine, | ||
"dw": Command.DeleteToNextWord, | ||
"dW": Command.DeleteToFullNextWord, | ||
"db": Command.DeleteToWordBegin, | ||
"dB": Command.DeleteToFullWordBegin, | ||
"de": Command.DeleteToWordEnd, | ||
"dE": Command.DeleteToFullWordEnd, | ||
"D" : Command.DeleteToLineEnd, | ||
|
||
"x": Command.DeleteChar, | ||
"X": Command.DeleteLastChar, | ||
|
||
"/": Command.Find, | ||
":": Command.EnterCommand, | ||
"v": Command.EnterVisualMode, | ||
"esc": Command.ExitMessages | ||
}; | ||
} | ||
|
||
export function newDefaultInsertKeymap() : {[key: string]: Command} { | ||
return { | ||
"i": Command.InsertAtCursor, | ||
"I": Command.InsertAtLineBegin, | ||
"a": Command.InsertAfterCursor, | ||
"A": Command.InsertAtLineEnd, | ||
"o": Command.InsertNewLineBelow, | ||
"O": Command.InsertNewLineAbove, | ||
}; | ||
} | ||
|
||
export function newDefaultVisualKeymap() : {[key: string]: Command} { | ||
return { | ||
"v": Command.EnterVisualMode | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.