A textobject-oriented vscode keymap. Inspired by vim, kakoune and helix.
Different from vim, oomotion modes refer to textobject selection & navigation mode. In each mode, your cursor will always select a specific kind of object and all navigations are based on that textobject. For example, in word
mode, your cursor always selects a word in your document and you can use hl
to navigate the previous/next word. And in line
mode, your cursor always selects a line and you can use jk
to navigate the previous/next line.
The following is all modes supported by current version of oomotion:
character
: Select & navigate by a single character each time.word
: Select & navigate by a word[\p{L}\p{N}_@$#]+
or consecutive symbols[\p{S}\p{P}\p{M}]+
or a single delimiter[()[]{}<>,;'"]
each time. For example,let b_ne = !(a.b != c)
contains wordslet
,b_ne
,=
,!
,(
,a
,.
,b
!=
,c
,)
.small-word
: Similar toword
, but select a inner word in camel case or snake case. For example,OoMotion VSCode oomotion_vscode
containssmallword
sOo
,Motion
,VSCode
,oomotion
,vscode
.big-word
: Similar toword
, but consider symbols[\p{S}\p{P}\p{M}]
like!.+-
same as letters and numbers. Ignore all delimiters. For example,let b_ne = !(a.b != c)
becomeslet
,b_ne
,=
,!
,a.b
!=
,c
.line
: Select & navigate by a single line each time.tree-sitter
: Select & navigate by a single tree sitter node each time.line-tree
: A line level tree navigator that based on indentation. (experimental)
Each mode has a unique colored box that highlights your textobject selection.
character
: grey solid boxword
: red solid boxsmall-word
: : red dotted boxbig-word
: : red dashed boxline
: : blue solid boxtree-sitter
: : yellow solid boxline-tree
: : yellow dashed box
Oomotion states is similar to vim's modes. There are three states available:
INSERT
: Insert text through keyboard.NORMAL
: All keyboard inputs are considered commands. Used for navigation and editing.SELECT
: All keyboard inputs are considered commands. Select multiple textobjects using navigation keys.
Each state has a unique cursor style as follows.
INSERT
: Thin line cursorNORMAL
: Thick line cursorSELECT
: Block cursor
You can also view the current state and mode on vscode's status bar.
Oomotion supports a range of keymaps. You can view & edit most of them on VS Code's Keyboard Shortcuts editor.
j k
: enterNORMAL
mode.
^
: entercharacter
mode.w
: enterword
mode.w w
: entersmall-word
mode.shift+w
: enterbig-word
mode.x
: enterline
mode.t
: entertree-sitter
mode.shift+t
: enterline-tree
mode.
Basic Navigation.
h
: Move left. Select the previous node intree-sitter
,line-tree
.l
: Move right. Select the next node intree-sitter
,line-tree
.j
: Move down. Select a child node intree-sitter
,line-tree
.k
: Move up. Select a parent node intree-sitter
,line-tree
.g h
: Go to the start of a line.g l
: Go to the end of a line.g j
: Go to the end of a file.g k
: Go to the start of a file.g g
: Go to line number.space j
: Move cursor down a page.space k
: Move cursor up a page.space space
: Center the view vertically.
Find by a single character.
f <char>
: Find the next textobject start with<char>
. Can select across multiple line (different from vim). Can also be used intree-sitter
,line-tree
.s <char>
: Find the previous textobject start with<char>
. Can select across multiple line (different from vim). Can also be used intree-sitter
,line-tree
.
Find by current textobject selection.
n
: Go to next occurence of selected textobject.b
: Go to previous occurence of selected textobject.
Navigate by easy-motion.
e
: Enter easy-motion mode.
Repeat and Redo.
enter
: repeat last navigation command.shift+enter
: redo last navigation command.
VS Code command key binding.
;
: VS CodeGo Back
command.shift+;
: VS CodeGo Forward
command.q
: VS CodeExpand Selection
command. Used to expand to the parent ast node. Used fortree-sitter
unsupport languages.shift+q
: VS CodeShrink Selection
command. Used to shrink to the child ast node. Used fortree-sitter
unsupport languages.
Add new cursors.
shift+h
: Add the left textobject as a new cursor. Add the previous named node to selections intree-sitter
mode.shift+l
: Add the right textobject as a new cursor. Add the next named node to selections intree-sitter
mode.shift+j
: Add the down textobject as a new cursor.shift+k
: Add the up textobject as a new cursor.shift+n
: Add the next occurence of current textobject as a new cursor.shift+b
: Add previous occurence of current textobject as a new cursor.
Enter INSERT
modes.
i
: Insert at left of selection.a
: Insert at right of selection.shift+i
: Insert at start of line.shift+a
: Insert at end of line.o
: Insert at a new line below.shift+o
: Insert at a new line above.c
: Change the current selection. (Delete the selection and insert here)shift+c
: Change the current selection with surrounding whitespace characters.
Delete the selection.
d
: Delete the current selection.shift+d
: Delete the current selection with surrounding whitespace characters.
Yank and Paste
y
: Yank selection.shift+y
: Yank line.p
: Paste after.shift+p
: Paste before.r
: Replace.
Undo & Redo
u
: Undo.shift+u
: Redo.
Swap and Duplicate Textobject.
alt+h
: Swap with the left object.alt+l
: Swap with the right object.alt+j
: Swap with the down object.alt+k
: Swap with the up object.alt+shift+h
: Duplicate a object left.alt+shift+l
: Duplicate a object right.alt+shift+j
: Duplicate a line below.alt+shift+k
: Duplicate a line up.
Evaluate CoffeeScript expression.
.
: Evaluate a coffeescript expression and replace the result with current selection. For example, press.
and then fill the input box with$.replace /red/g, 'blue'
will replace allred
in current selection intoblue
.#
: Evaluate a coffeescript expression and insert the result before current selection.$
: Evaluate a coffeescript expression and insert the result after current selection.m
: Run a predefined modifier function on current selection. For example,m camel
will convert current words into camel case.
Alignment command.
= <char>
: Align selected lines based on a character.
Indentation.
tab
: Indent selected lines.shift+tab
: Outdent selected lines.
Code Navigation.
g d
: Reveal definition.g shift+d
: Reveal definition aside.g t
: Go to type definition.g i
: Go to implementation.g r
: Go to references.g [
: Go to previous marker (error, warnning, etc).g ]
: Go to next marker (error, warnning, etc).space b
: Open the breadcumbs.space s
: Open VS Codes'sGo to Symbol in Editor
space s
: Open VS Codes'sGo to Symbol in Workspace
space h
: Show Definition Preview Hover.
Code Actions.
space f
: Format the document.space a
: Open code Actions.space r
: Code Rename.
[
: Previous Editor.]
: Next Editor.{
: Focus Left Group.}
: Focus Right Group.space [
: Move Editor to Left Group.space ]
: Move Editor to Right Group.space {
: New Editor Group to the Left.space }
: New Editor Group to the Right.space w
: Close Other Editors in Group.space shift+w
: Close All Editors in Group. }
Current supported tree-sitter grammars: bash
, c
, cpp
, go
, html
, java
, javascript
, json
, ocaml
, python
, rust
, typescirpt
. I can't compile many tree-sitter grammar projects in webassembly.
Most features works well on MacOS. Tell me if some features are different from what you expect. I'm maintaining this project. Issues are welcome!
0.0.2
: OptimizeMove Up/Down
inword
mode to make multicursor easier to use. Add a icon and keywords.