-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
tianshu
committed
Oct 16, 2021
1 parent
8e23eb0
commit 3d4ba1e
Showing
5 changed files
with
81 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
[ | ||
{"keys": ["i"], "command": "insert_mode", "context": [{"key": "setting.command_mode"}]}, | ||
{"keys": ["a"], "command": "insert_mode_append", "context": [{"key": "setting.command_mode"}]}, | ||
|
||
// character movements | ||
{"keys": ["h"], "command": "move", "context": [{"key": "setting.command_mode"}], | ||
"args": {"by": "characters", "forward": false}}, | ||
{"keys": ["t"], "command": "move", "context": [{"key": "setting.command_mode"}], | ||
"args": {"by": "characters", "forward": true}}, | ||
{"keys": ["p"], "command": "move", "context": [{"key": "setting.command_mode"}], | ||
"args": {"by": "lines", "forward": false}}, | ||
{"keys": ["n"], "command": "move", "context": [{"key": "setting.command_mode"}], | ||
"args": {"by": "lines", "forward": true}}, | ||
|
||
// character expand | ||
{"keys": ["H"], "command": "move", "context": [{"key": "setting.command_mode"}], | ||
"args": {"by": "characters", "forward": false, "extend": true}}, | ||
{"keys": ["T"], "command": "move", "context": [{"key": "setting.command_mode"}], | ||
"args": {"by": "characters", "forward": true, "extend": true}}, | ||
{"keys": ["P"], "command": "move", "context": [{"key": "setting.command_mode"}], | ||
"args": {"by": "lines", "forward": false, "extend": true}}, | ||
{"keys": ["N"], "command": "move", "context": [{"key": "setting.command_mode"}], | ||
"args": {"by": "lines", "forward": true, "extend": true}}, | ||
|
||
// escape | ||
{"keys": ["escape"], "command": "command_mode", "context": [{"key": "setting.is_widget", "operator": "equal", "operand": false}]} | ||
] |
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,4 @@ | ||
{ | ||
"block_caret": true, | ||
"command_mode": true, | ||
} |
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 |
---|---|---|
@@ -1,4 +1,9 @@ | ||
# sublime-meow | ||
Modal Editing on Sublime Text 4 | ||
|
||
 | ||
 | ||
|
||
# Development Guide | ||
|
||
Link this project to `~/.config/sublime-text/Packages/`. | ||
|
||
Sublime will reload plugins automatically after you make any changes. |
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,4 @@ | ||
{ | ||
"command_mode": false, | ||
"block_caret": false, | ||
} |
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,39 @@ | ||
import sublime | ||
import sublime_plugin | ||
|
||
class InsertModeCommand(sublime_plugin.TextCommand): | ||
""" | ||
Switch to INSERT mode, put carets at the start of each selection. | ||
""" | ||
def run(self, edit): | ||
buf = self.view | ||
if buf.is_read_only(): | ||
sublime.status_message('Buffer is read only') | ||
return | ||
|
||
buf.settings().set(key='block_caret', value=False) | ||
buf.settings().set(key='command_mode', value=False) | ||
|
||
class InsertModeAppendCommand(sublime_plugin.TextCommand): | ||
""" | ||
Switch to INSERT mode, put carets at the end of each selection. | ||
""" | ||
def run(self, edit): | ||
buf = self.view | ||
if buf.is_read_only(): | ||
sublime.status_message('Buffer is read only') | ||
return | ||
|
||
self.view.run_command("move", {"by": "characters", "forward": True}) | ||
|
||
buf.settings().set(key='block_caret', value=False) | ||
buf.settings().set(key='command_mode', value=False) | ||
|
||
class CommandModeCommand(sublime_plugin.TextCommand): | ||
""" | ||
Switch to COMMAND mode. | ||
""" | ||
def run(self, edit): | ||
buf = self.view | ||
buf.settings().set(key='block_caret', value=True) | ||
buf.settings().set(key='command_mode', value=True) |