-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvim.py
72 lines (57 loc) · 1.99 KB
/
vim.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
from talon import Context, Module, actions
import pyperclip
mod = Module()
ctx = Context()
ctx.matches = "title: /VIM/"
@mod.action_class
class Actions:
def vim_normal_mode(command: str):
"""Execute in normal mode"""
def vim_normal_mode_key(command: str):
"""Execute key combination in normal mode"""
def vim_insert_mode(command: str, key: str = "i"):
"""Execute in insert mode"""
def vim_visual_mode(command: str):
"""Execute in visual mode"""
def vim_vertical_visual_mode(command: str):
"""Execute in vertical visual mode"""
def vim_command_mode(command: str):
"""Execute in command mode"""
def vim_select_lines(number_string: str):
"""Select multiple lines"""
@ctx.action_class("user")
class VimActions:
def vim_normal_mode(command: str):
"""Execute in normal mode"""
actions.key("escape")
actions.insert(command)
def vim_normal_mode_key(command: str):
"""Execute key combination in normal mode"""
actions.key("escape")
actions.key(command)
def vim_insert_mode(command: str, key: str = "i"):
"""Execute in insert mode"""
actions.key("escape")
actions.key(key)
actions.insert(command)
actions.key("escape")
def vim_visual_mode(command: str):
"""Execute in visual mode"""
actions.key("escape")
actions.insert(f"v{command}")
def vim_vertical_visual_mode(command: str):
"""Execute in vertical visual mode"""
actions.key("escape")
actions.key(ctrl-v)
actions.insert(command)
def vim_command_mode(command: str):
"""Execute in command mode"""
actions.key("escape")
actions.insert(":")
actions.user.pyperclip_insert(command)
actions.key("enter")
def vim_select_lines(number_string: str):
"""Select multiple lines"""
number = int(number_string) - 1
actions.key("escape")
actions.insert(f"v{number}j")