🚀 Obsidian Vim 快捷键实操教程 🚀

总标题:自定义 Obsidian Vim 模式快捷键


1。基本设置

1.1 Key Unbindings
取消原有的默认绑定,确保我们的新快捷键可以正常工作:

1
2
3
nunmap s
vunmap s
unmap <Space>

2。基础应用命令

2.1 重载 Obsidian

1
nmap <Space>rc :reload

2.2 其他基础命令

  • 后退:<C-i> :back
  • 前进:<C-o> :forward
    … [其它命令可以类似添加]

3。标签和工作区命令

3.1 关闭标签页

1
nmap Q :tabclos

3.2 标签和工作区相关命令

  • 下一个标签:<Space>th :tabnext
  • 上一个标签:<Space>tl :tabprev
    … [其它命令可以类似添加]

4。导航和链接命令

4.1 跳转到父级链接

1
nmap gu :goParent

4.2 其他导航和链接命令
… [根据你的配置,类似地添加]


5。编辑和折叠命令

5.1 折叠/展开全部

1
2
nmap za :uf
nmap <Space>O :foldall

5.2 其他编辑和折叠命令
… [根据你的配置,类似地添加]


6。插件和实用工具命令

6.1 打开插件

1
nmap <Space>po :plugope

6.2 其他插件和实用工具命令
… [根据你的配置,类似地添加]


7。代码块命令

7.1 添加特定类型的代码块 (普通模式)

1
nmap <Space>cad :codeblock_adm

7.2 添加特定类型的代码块 (视觉模式)

1
vmap <Space>cad :codeblock_select_adm

7.3 其他代码块命令
… [根据你的配置,类似地添加]


8。周围命令

8.1 添加 Wiki 链接

1
nmap [[ :surround_wiki

8.2 其他周围命令
… [根据你的配置,类似地添加]


9。聚焦命令

9.1 焦点右移

1
nmap <Space>l :focusRight

9.2 其他聚焦命令
… [根据你的配置,类似地添加]


10。基本命令

10.1 保存

1
nmap S :w<CR>

10.2 其他基本命令
… [根据你的配置,类似地添加]


11-18。[根据上述模式继续完成]


注意:在实际使用中,需要先确保 Obsidian 的 Vim 插件已经启用,并确保相关的插件和功能都已经安装和启动。


11。移动和焦点

11.1 焦点上移

1
nmap <Space>k :focusTop

11.2 其他移动和焦点命令
… [根据你的配置,类似地添加]


12。标签和折叠命令

12.1 展开所有

1
nmap za :uf

12.2 其他标签和折叠命令
… [根据你的配置,类似地添加]


13。编辑和正则

13.1 删除所有空行

1
nmap <Space>rb :%s/^\s*$\n//g

13.2 其他编辑和正则命令
… [根据你的配置,类似地添加]


14。插件和特殊命令

14.1 打开链接

1
nmap <Space>ol :openLink

14.2 其他插件和特殊命令
… [根据你的配置,类似地添加]


15。代码块命令 (普通模式)

15.1 添加 Admin 代码块

1
nmap <Space>cad :codeblock_adm

15.2 其他代码块命令 (普通模式)
… [根据你的配置,类似地添加]


16。代码块命令 (视觉模式)

16.1 选择并添加 Admin 代码块

1
vmap <Space>cad :codeblock_select_adm

16.2 其他代码块命令 (视觉模式)
… [根据你的配置,类似地添加]


17。周围命令

17.1 使用双引号包围

1
nmap s" :surround_double_quotes

17.2 其他周围命令
… [根据你的配置,类似地添加]


18。系统剪贴板

18.1 复制到系统剪贴板

1
vmap Y "+y

19 code

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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
" Key unbindings
nunmap s
vunmap s
unmap <Space>
" ----------------------
" BASIC APPLICATION COMMANDS
" ----------------------
exmap reload obcommand app:reload
exmap back obcommand app:go-back
exmap forward obcommand app:go-forward
exmap zoomIn obcommand obsidian-zoom:zoom-in
exmap zoomOut obcommand obsidian-zoom:zoom-out

" ----------------------
" TAB AND WORKSPACE COMMANDS
" ----------------------
exmap Q :tabclose
exmap tabprev obcommand workspace:next-tab
exmap tabnext obcommand workspace:previous-tab
exmap tabundo obcommand workspace:undo-close-pane
exmap tabclos obcommand workspace:close
exmap movetwind obcommand workspace:move-to-new-window
exmap closewind obcommand workspace:close-window
exmap titlechange obcommand workspace:edit-file-title

" ----------------------
" NAVIGATION AND LINK COMMANDS
" ----------------------
exmap goParent obcommand breadcrumbs:jump-to-first-up
exmap openLink obcommand editor:follow-link
exmap openintab obcommand editor:open-link-in-new-leaf
exmap opensplit obcommand editor:open-link-in-new-split
exmap openinwid obcommand editor:open-link-in-new-window
exmap easymotion obcommand mrj-jump-to-link:activate-jump-to-anywhere
exmap easylink obcommand mrj-jump-to-link:activate-jump-to-link

" ----------------------
" EDITING AND FOLDING COMMANDS
" ----------------------
exmap togglefold obcommand editor:toggle-fold
exmap uf obcommand editor:unfold-all
exmap foldall obcommand editor:fold-all
exmap foldless obcommand editor:fold-less
exmap foldmore obcommand editor:fold-more
exmap contextMenu obcommand editor:context-menu

" ----------------------
" PLUGIN AND UTILITY COMMANDS
" ----------------------
exmap plugope obcommand hotkey-helper:open-plugins
exmap plugbro obcommand hotkey-helper:browse-plugins
exmap plugset obcommand hotkey-helper:open-settings
exmap plughtk obcommand hotkey-helper:open-hotkeys
exmap plugurl obcommand obsidian42-brat:BRAT-openGitHubZRepository
exmap qkadd_date obcommand quickadd:choice:5480c3bd-c30c-4809-ab15-53359aa8b307

" ----------------------
" CODE BLOCK COMMANDS
" ----------------------
exmap codeblock_adm obcommand code-block-from-selection:6a0b839c-1e63-40bf-a82d-d7d2f9081313
exmap codeblock_select_adm jscommand { editor.setSelections([selection]); this.app.commands.commands['code-block-from-selection:6a0b839c-1e63-40bf-a82d-d7d2f9081313'].callback() }
exmap codeblock1 obcommand code-block-from-selection:5551a29b-6fbe-419d-8c9a-ad69dcf338bb
exmap codeblock_select1 jscommand { editor.setSelections([selection]); this.app.commands.commands['code-block-from-selection:5551a29b-6fbe-419d-8c9a-ad69dcf338bb'].callback() }
exmap codeblock2 obcommand code-block-from-selection:e3dea0f5-37f2-4d79-ae58-490af3228069
exmap codeblock_select2 jscommand { editor.setSelections([selection]); this.app.commands.commands['code-block-from-selection:e3dea0f5-37f2-4d79-ae58-490af3228069'].callback() }
exmap codeblock3 obcommand code-block-from-selection:0517e550-5f21-44b6-8232-d4cb3b76f6c4
exmap codeblock_select3 jscommand { editor.setSelections([selection]); this.app.commands.commands['code-block-from-selection:0517e550-5f21-44b6-8232-d4cb3b76f6c4'].callback() }
exmap codeblock4 obcommand code-block-from-selection:fa4231fd-b32f-4458-9b87-8deb65a73f3f
exmap codeblock_select4 jscommand { editor.setSelections([selection]); this.app.commands.commands['code-block-from-selection:fa4231fd-b32f-4458-9b87-8deb65a73f3f'].callback() }
exmap codeblock5 obcommand code-block-from-selection:0b696aea-5954-41cd-b749-11e121481aad
exmap codeblock_select5 jscommand { editor.setSelections([selection]); this.app.commands.commands['code-block-from-selection:0b696aea-5954-41cd-b749-11e121481aad'].callback() }

" ----------------------
" SURROUND COMMANDS
" ----------------------
exmap surround_wiki surround [[ ]]
exmap surround_double_quotes surround " "
exmap surround_single_quotes surround ' '
exmap surround_brackets surround ( )
exmap surround_square_brackets surround [ ]
exmap surround_curly_brackets surround { }

" ----------------------
" FOCUS COMMANDS
" ----------------------
exmap focusRight obcommand editor:focus-right
exmap focusLeft obcommand editor:focus-left
exmap focusTop obcommand editor:focus-top
exmap focusBottom obcommand editor:focus-bottom
exmap nextHeading jsfile .mdHelpers.js {jumpHeading(true)}
exmap prevHeading jsfile .mdHelpers.js {jumpHeading(false)}

" ----------------------
" BASIC COMMANDS
" ----------------------
nmap <Space>rc :reload
nmap U <C-r>
nmap S :w<CR>
nmap Q :tabclos
nmap tc :titlechange

" ----------------------
" MOVEMENT AND FOCUS
" ----------------------
nmap <C-i> :back
nmap <C-o> :forward
nmap <Space>l :focusRight
nmap <Space>h :focusLeft
nmap <Space>k :focusTop
nmap <Space>j :focusBottom
nmap } :nextHeading
nmap { :prevHeading
nmap H ^
nmap L $
nmap ; :

" ----------------------
" TAB AND FOLDING COMMANDS
" ----------------------
nmap za :uf
nmap <Space>o :togglefold
nmap <Space>O :foldall
nmap <Space>th :tabnext
nmap <Space>tl :tabprev

" ----------------------
" EDITING AND REGEX
" ----------------------
nmap <Space>rb :%s/^\s*$\n//g
nmap <Space>rl ::%s/\s*$//g

" ----------------------
" PLUGIN AND SPECIAL COMMANDS
" ----------------------
nmap <Space>ol :openLink
nmap <Space>ot :openintab
nmap <Space>os :opensplit
nmap <Space>ow :openinwid
nmap <Space>po :plugope
nmap <Space>pb :plugbro
nmap <Space>ps :plugset
nmap <Space>ph :plughtk
nmap <Space>pu :plugurl
nmap gu :goParent
nmap gw :easymotion
nmap gl :easylink
nmap z= :contextMenu
nmap <Space>td :qkadd_date

" ----------------------
" CODE BLOCK COMMANDS (NORMAL MODE)
" ----------------------
nmap <Space>cad :codeblock_adm
nmap <Space>cpy :codeblock1
nmap <Space>cjs :codeblock2
nmap <Space>csh :codeblock3
nmap <Space>cvm :codeblock4
nmap <Space>cda :codeblock5

" ----------------------
" CODE BLOCK COMMANDS (VISUAL MODE)
" ----------------------
vmap <Space>cad :codeblock_select_adm
vmap <Space>cpy :codeblock_select1
vmap <Space>cjs :codeblock_select2
vmap <Space>csh :codeblock_select3
vmap <Space>cvm :codeblock_select4
vmap <Space>cda :codeblock_select5
vmap z= :contextMenu

" ----------------------
" SURROUND COMMANDS
" ----------------------
nmap [[ :surround_wiki
nmap s" :surround_double_quotes
nmap s' :surround_single_quotes
nmap sb :surround_brackets
nmap sn :surround_square_brackets
nmap sm :surround_curly_brackets

" ----------------------
" YANK TO SYSTEM CLIPBOARD
" ----------------------
vmap Y "+y