vim 学习

快捷键

[[命令快捷键#Vim]]

vim 基本使用

一般模式

通过 vim + 文件名,进入 vim 环境(test. txt 可以是当前目录已存在的文件,也可以是当前目录不存在的文件。):

此时,我们在 vim 的一般模式下,如果 test. txt 文件有内容,我们可以通过:

  • j 下移光标
  • k 上移光标
  • h 左移光标
  • l 右移光标

如果用的不习惯,上下左右方向键也可以移动光标。

编辑模式

在一般模式下,输入 a i o 可以进入编辑模式,编辑模式下,我们可以输入文本修改文件内容。

a i o 的区别如下:

  • a:在当前光标下一位插入
  • i:当前光标处插入
  • o:换行并创建全新空白行,并在行首插入

在编辑模式下,我们点击 esc 键即可回到一般模式。

命令行模式

在一般模式下,输入分号,就会进入命令行模式。在命令行中,可以输入不同的指令或者字符串以实现不同的功能。其中涉及的最常用的功能包括了两类:

  • 退出 vim
  • 当前文本中,搜索字符串

进入命令行模式后,有三种方式来退出 vim:

  • 当前文件没有做任何改变时,输入 q 指令,退出 vim 环境
  • 当前文件做了一些修改,如果想放弃已修改的内容,输入 q! 指令,退出 vim 环境
  • 当前文件做了一些修改,如果想保存已修改的内容,输入 wq 指令,退出 vim 环境

进入命令行模式后,我们还可以输入 / + 字符串,点击回车键,进入搜索模式,点击 N 键,光标就会在匹配处依次跳动。

在一般模式下,我们也可以直接输入 / + 字符串进行搜索。

其他

IDE 使用 Vim 插件,喜欢点击鼠标切换光标位置,总觉得按键盘切换太麻烦了 - V2EX

IntelliJ IDEA 必备插件之键盘流篇-CSDN博客

ayamir/nvimdots: A well configured and structured Neovim.

中文问题

Windows

解决Windows下(Neo)Vim中文输入法的切换问题 - Leaos - 博客园

    1. 下载AutoHotKey 打开 AutoHotKey 官网下载相应软件,点击 Download Current Version 即可。 下载完成后,进行安装。安装包很小,仅仅 3MB。选择默认安装,或者自定义安装都可以。 自定义安装仅仅更改安装路径即可,其它使用默认即可。

Mac

ieda

https://smart-input-source-1315501506.cos.ap-shanghai.myqcloud.com/guidedoc/mac-started-guide

MacOS 底下使用Vundle或者Vim-plug 配置vim - 简书

安装 plugged

  • 使用vim-plug管理插件

  • 清除之前的设置
    sudo rm -rf ~/.vim sudo rm .vimrc

  • 拷贝vimrc

    1
    git clone https://github.com/yxrdydh/vimrc_Mac.git ~/.vim/

    `

  • 安装插件管理vim-plug.vim

1
2
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

如何让 Neovim 中文输入时自动切换输入法 - jdhao’s digital space

  • vim-barbaric

  • vim-barbaric 是一款帮助用户自动设置输入法模式的插件。

  • 安装依赖

  • 在 macOS 下,需要额外安装 xkbswitch-macosx

1
curl -o /usr/local/bin/xkbswitch https://raw.githubusercontent.com/myshov/xkbswitch-macosx/master/bin/xkbswitch
  • 然后使用插件管理器安装该插件即可:
    1
    Plug 'rlue/vim-barbaric'
  • 该插件开箱即用,无需额外设置。

vim-plug简介

  • 安装在 GitHub 仓库中的插件
  • 如果您要安装的插件在 GitHub 仓库中, 那么,配置的格式如下:
  • Plug ‘userName/repoName’
  • 执行这个指令的时候,首先检测该插件是否已经下载到本地了,如果没有下载, 就会使用 git 下载,下载的方式如下:
  • git -C ~/.vim/bundle clone --recursive https://github.com/tpope/vim-fugitive.git
  • 下载到 ~/.vim/bundle/vim-fugitive 目录中。
1
git -C ~/.vim/bundle clone --recursive https://github.com/rlue/vim-barbaric.git
  • 安装插件 在vim中 :PlugInstall

call plug#begin(‘~/.vim/plugged’)
call plug#end()

idea配置

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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
" ================================================================================================  
" 🍰🍰🍰 Extensions 🍰🍰🍰
" ================================================================================================
Plug 'preservim/nerdtree'

"下列插件需要在IDEA中下载
"ideaVim
"IdeaVim-EasyMotion
"IdeaVimExtension
"which-key
"CodeGlance Pro
"TranslateAction



" ================================================================================================
" 🐧🐧🐧 Basic settings 🐧🐧🐧
" ================================================================================================
"设置在光标距离窗口顶部或底部一定行数时,开始滚动屏幕内容的行为
set scrolloff=10

"--递增搜索功能:在执行搜索(使用 / 或 ? 命令)时,
"Vim 会在您输入搜索模式的过程中逐步匹配并高亮显示匹配的文本。
set incsearch

"--在搜索时忽略大小写
set ignorecase

"--将搜索匹配的文本高亮显示
set hlsearch

"--设置相对行号 和 当前行的绝对行号
set number relativenumber

"--设置返回normal模式时回到英文输入法
set keep-english-in-normal



" ================================================================================================
" 🌍🌍🌍 No Leader Keymaps 🌍🌍🌍
" ================================================================================================
"--普通模式下使用回车键,向下/向上 增加一行
nmap <CR> o<Esc>
nmap <S-Enter> O<Esc>

"--在普通和插入模式下,向下交换行/向上交换行
nnoremap <C-j> :m +1<CR>
nnoremap <C-k> :m -2<CR>
inoremap <C-j> <Esc> :m +1<CR>gi
inoremap <C-k> <Esc> :m -2<CR>gi

"--将 jj 和 jk 映射为 <Esc>
"jj和jk为主流配置,可按喜好自行调整
inoremap jj <ESC>

"--格式化(规范化)文本,即对选定的文本进行换行或重排,适应指定的文本宽度。
"全文规范化:Ctrl+Alt+l
map Q gq
"跳转到下一个错误或警告
nmap ge <action>(GotoNextError)
"在源代码和测试代码之间快速切换
nmap gt <action>(GotoTest)
"将光标移动到上一个方法的声明处
nmap gm <action>(MethodUp)
" last changed in current buffer(file)
"跳转到当前接口或抽象类的实现处
nmap ga <action>(GotoImplementation)

" bookmark 切换书签
nmap ma <action>(ToggleBookmark)

"切换标签页
nmap L <action>(NextTab)
nmap H <action>(PreviousTab)

"将Ctrl + s 映射为保存文档(也可以在VIM设置里将此快捷键设置为IDEA的快捷键)
nmap <C-S> <action>(SaveAll)
imap <C-S> <Esc><action>(SaveAll)

" e: Extract
" extract method/function 将选中的代码片段提取为一个独立的方法(Ctrl + Alt + M)
vmap <leader>em <action>(ExtractMethod)
" extract constant (引入常量)的重构操作:将选中的代码片段抽取为一个常量,并自动替换选中的代码片段为新的常量引用(Ctrl + Alt + C)
vmap <leader>ec <action>(IntroduceConstant)
" extract field (引入字段)的重构操作:将选中的代码片段转化为一个新的字段,并自动将选中的代码片段替换为对该字段的引用(Ctrl + Alt + F)
vmap <leader>ef <action>(IntroduceField)
" extract variable (引入变量)的重构操作:将选中的代码片段抽取为一个新的变量,并自动替换选中的代码片段为新的变量引用(Ctrl + Alt + V)
vmap <leader>ev <action>(IntroduceVariable)



" ================================================================================================
" ⭐️⭐️⭐️ Leader Keymaps ⭐️⭐️⭐️ =====================================" ================================================================================================
"--将<leader>设置为 空格 键
"可自行更改,只需更改双引号内的内容即可
"推荐<leader>: "空格" ";" "\" "-" ","
let mapleader = " "



" ================================================================================================
" 👻👻👻 Which-Key 👻👻👻
" ================================================================================================

"which-key的官方推荐配置
set which-key
set notimeout



" ================================================================================================
" 🌞🌞🌞 目录-食用手册 🌞🌞🌞
" ================================================================================================

"===================================== A =====================================
" a:
"===================================== B =====================================
" b:
"===================================== C =====================================
" c: CodeAndClose-[目录]🎈
" cc: CodeCompletion-自动补全
" cd: CloseEditor-关闭当前标签页
" ca: CloseAllEditors-关闭所有标签页
"===================================== D =====================================
" d: DebugOrDelete-[目录]🎈
" dp: BreakPoint-打断点/解除断点
" db: DeBug-调试
" [V]d: DeleteAndCopyClipboard-在可视模式中:删除选择的文本并复制到剪切板
"===================================== E =====================================
" e: ToggleExplorer ⭐️ 激活项目工具窗口"===================================== F =====================================
" f: Find/Format ⭐🎈[目录]
" ff: FindFile-快速 导航/查找 项目中的其他文件(Ctrl + n)
" fl: FindFileLocation-将当前编辑的文件在项目视图中进行选中定位(Alt + F1)
" ft: FindText-在整个项目中查找指定的文本、关键字或正则表达式,包括代码文件、配置文件和其他文件等(Ctrl + Shift + F)
" fc: Commands-打开 "Find Action"(查找动作)对话框(Ctrl + Shift + A)
" fm: Format-重新格式化代码,使其符合预定义的代码样式和规范 and 优化导入语句,删除未使用的导入,并将导入语句按字母顺序进行排列
"===================================== G =====================================
" g: GitOrGenerate 🎈[目录]
" gr: RollbackHunk-执行版本控制(VCS)的回滚操作,将修改的代码还原到之前的版本
" gc: GenerateConstructor-生成构造函数
" gg: GenerateGetter-生成getter函数
" gs: GenerateSetter-生成setter函数
" ga: GenerateGetterAndSetter-生成getter和setter函数
" ge: GenerateEquals-生成equals和hashcode的重写方法
" gd: ShowTabbedFileHistory-显示文件的版本控制历史(git)
"===================================== H =====================================
" h: PreviousTab-切换到上一个标签页
"===================================== I =====================================
" i: Insert ⭐快速查找并跳转到下一个以 ( 开始的函数或方法调用的位置️
"===================================== J =====================================
" j: InsertSemicolon⭐️ 普通模式下在行尾一个分号,然后进入插入模式并在当前行的下方新建一行"===================================== K =====================================
" k:
"===================================== L =====================================
" l: NextTab-切换到下一个标签页
"===================================== M =====================================
" m: CodeGlance-打开/关闭地图(需要CodeGlance Pro插件)
"===================================== N =====================================
" n: NERDTreeOrNo ⭐️[目录]🎈
" nn: NERDTreeFocus-将使焦点转移到 NERDTree 窗口(配置在NERDTree专栏)
" nl: NoHighlight-取消搜索高亮显示
" nd: NewDir-新建文件夹
" nc: NewClass-新建类
"===================================== O =====================================
" o:
"===================================== P =====================================
" p: PasteClipboardDown-从剪切板粘贴到下面行
" P: PasteClipboardUp-从剪切板粘贴到上面行
" [V]p: PasteClipboardDown-在可视模式中:从剪切板粘贴到下面行
" [V]P: PasteClipboardUp-在可视模式中:从剪切板粘贴到上面行
"===================================== Q =====================================
" q:
"===================================== R =====================================
" r: Run/Re ⭐️[目录]🎈
" ru: RunClass-运行当前编辑器中的文件或类(Shift + F10)
" rr: ReRun-重新运行最近一次运行的程序或测试(Ctrl + Shift + F10)
" rt: ReRunTests-重新运行最近一次运行的测试(Unit Tests)(Ctrl + Shift + F10)
" rn: Rename-在代码中快速更改一个标识符的名称,并自动处理所有相关的引用(Shift + F6)
"===================================== S =====================================
" s: Show ⭐️[目录]🎈
" ss: ShowFileStructure-显示当前打开文件的文件结构弹出窗口,其中包含文件中的类、方法、字段等结构(Alt + 7)
" sb: ShowBookmarks-显示书签(Bookmarks)工具窗口,其中包含当前文件中设置的书签列表(Ctrl + F11)
" sp: ShowParameterInfo-用于显示方法或函数的参数信息(Ctrl + p)
"===================================== T =====================================
" t: Translate-翻译(需要Translate插件)
"===================================== U =====================================
" u:
"===================================== V =====================================
" v:
"===================================== W =====================================
" w: Window ⭐️[目录]🎈
" wo: maximize-取消分割窗口 并 隐藏所有编辑器窗口
" wl: splitWindowVertically-在垂直方向上分割编辑器窗口,将一个编辑器窗口拆分为两个垂直排列的窗格
" wc: closeActiveWindow-关闭当前窗口或分割窗格
" wh: HideActiveWindow-关闭提示窗口
"===================================== X =====================================
" x:
"===================================== Y =====================================
" y: CopyClipboard-将选中行复制到剪切板
" [V]y: CopyClipboard-在可视模式中:将选中文字复制到剪切板
"===================================== Z =====================================
" z: zip(fold) ⭐️[目录]🎈
" zo: unZipAll-展开所有代码折叠区域(Ctrl + Shift + 加号键)
" zc: ZipAll-折叠所有代码折叠区域(Ctrl + Shift + 减号键)
"=============================================================================
"=============================================================================
"=============================================================================



" ================================================================================================
" 🌟🌟🌟 <leader>详细配置 🌟🌟🌟
" ================================================================================================
"========= NULL ========
"这一行为在按下<leader>后显示的,甭管就行
let g:WhichKeyDesc_LeaderKeymap= "<leader> 🌟🌟🌟LeaderKeymap🌟🌟🌟"


"========== b ==========


"========== c ==========
let g:WhichKeyDesc_CodeAndClose = "<leader>c CodeAndClose"

"关闭所有标签页
let g:WhichKeyDesc_CodeAndClose_CloseAllEditors = "<leader>ca CloseAllEditors"
nmap <leader>ca <action>(CloseAllEditors)
"关闭当前标签页
let g:WhichKeyDesc_CodeAndClose_CloseEditor = "<leader>ce CloseEditor"
nmap <leader>ce :action CloseEditor<CR>
"代码自动补全
let g:WhichKeyDesc_CodeAndClose_CodeCompletion = "<leader>cc CodeCompletion)
nmap <leader>cc <action>(CodeCompletion)


"========== d ==========
let g:WhichKeyDesc_DeBugOrDelete= "<leader>d DebugOrDelete"
"打断点/解除断点
let g:WhichKeyDesc_DebugOrDelete_BreakPoint = "<leader>dp BreakPoint"
nmap <leader>dp <Action>(ToggleLineBreakpoint)
"调试
let g:WhichKeyDesc_DebugOrDelete_DeBug = "<leader>db DeBug"
nmap <leader>db <Action>(Debug)
"在可视模式中:删除选择的文本并复制到剪切板
let g:WhichKeyDesc_DebugOrDelete_DeleteAndCopyToClipboard = "<leader>dd DeleteAndCopyClipboard"
vmap <leader>dd "+d


"========== e ==========
"激活项目工具窗口(Alt + 1)
let g:WhichKeyDesc_ToggleExplorerOrExtract = "<leader>e ToggleExplorer"
nmap <leader>e <action>(ActivateProjectToolWindow)


"========== f ==========
let g:WhichKeyDesc_FindOrFormat = "<leader>f FindOrFormat"

"快速 导航/查找 项目中的其他文件(Ctrl + n)
let g:WhichKeyDesc_FindOrFormat_FindFile = "<leader>ff FindFile"
nmap <leader>ff <action>(GotoFile)
"将当前编辑的文件在项目视图中进行选中定位(Alt + F1)
let g:WhichKeyDesc_FindOrFormat_FindFileLocation = "<leader>fl FindFileLocation"
nmap <leader>fl <action>(SelectInProjectView)
"在整个项目中查找指定的文本、关键字或正则表达式,包括代码文件、配置文件和其他文件等(Ctrl + Shift + F)
let g:WhichKeyDesc_FindOrFormat_FindText = "<leader>ft FindText"
nmap <leader>ft <action>(FindInPath)
"打开 "Find Action"(查找动作)对话框(Ctrl + Shift + A)
let g:WhichKeyDesc_FindOrFormat_Commands = "<leader>fc Commands"
nmap <leader>fc <action>(GotoAction)
"重新格式化代码,使其符合预定义的代码样式和规范 \| 优化导入语句,删除未使用的导入,并将导入语句按字母顺序进行排列
let g:WhichKeyDesc_FindOrFormat_Format = "<leader>fm Format"
nmap <leader>fm <action>(ReformatCode) \| <action>(OptimizeImports)


"========== g ==========
let g:WhichKeyDesc_GitOrGenerate = "<leader>g GitOrGenerate"

"执行版本控制(VCS)的回滚操作,将修改的代码还原到之前的版本
let g:WhichKeyDesc_GitOrGenerate_RollbackHunk = "<leader>gr RollbackHunk"
nmap <leader>gr :action Vcs.RollbackChangedLines<CR>
"生成构造器
let g:WhichKeyDesc_GitOrGenerate_GenerateConstructor = "<leader>gc GenerateConstructor"
nmap <leader>gc :action GenerateConstructor<CR>
"生成getter
let g:WhichKeyDesc_GitOrGenerate_GenerateGetter = "<leader>gg GenerateGetter"
nmap <leader>gg :action GenerateGetter<CR>
"生成setter
let g:WhichKeyDesc_GitOrGenerate_GenerateSetter = "<leader>gs GenerateSetter"
nmap <leader>gs :action GenerateSetter<CR>
"生成setter和getter
let g:WhichKeyDesc_GitOrGenerate_GenerateGetterAndSetter = "<leader>ga GenerateGetterAndSetter"
nmap <leader>ga <action>(GenerateGetterAndSetter)
"生成 equals() 和 hashcode() 的重写方法
let g:WhichKeyDesc_GitOrGenerate_GenerateEquals = "<leader>ge GenerateEquals"
nmap <leader>ge <action>(GenerateEquals)
"生成toString
let g:WhichKeyDesc_GitOrGenerate_GenerateToString = "<leader>ge GenerateToString"
nmap <leader>gt <action>(Actions.ActionsPlugin.GenerateToString)
"diff 显示文件的版本控制历史(git)
nmap <leader>gd <action>(Vcs.ShowTabbedFileHistory)
let g:WhichKeyDesc_DebugOrDelete_ShowTabbedFileHistory = "<leader>gd ShowTabbedFileHistory"


"========== h ==========
"切换到上一个标签页
let g:WhichKeyDesc_PreviousTab = "<leader>h PreviousTab"
nmap <leader>h :action PreviousTab<CR>


"========== i ==========
"快速查找并跳转到下一个以 ( 开始的函数或方法调用的位置️
let g:WhichKeyDesc_InsertAfterBrackets = "<leader>i InsertAfterBrackets"
nmap <leader>i f(a


"========== j ==========
"普通模式下在行尾一个分号,然后进入插入模式并在当前行的下方新建一行
let g:WhichKeyDesc_InsertSemicolon = "<leader>j InsertSemicolon"
nmap <leader>j A;<ESC>o


"========== l ==========
"切换到下一个标签页
let g:WhichKeyDesc_NextTab = "<leader>l NextTab"
nmap <leader>l :action NextTab<CR>


"========== m ==========
"打开/关闭 代码小地图
let g:WhichKeyDesc_CodeGlance = "<leader>m CodeGlance"
nmap <leader>m <action>(CodeGlance.toggle)


"========== n ==========
let g:WhichKeyDesc_NERDTreeOrNew = "<leader>n NERDTreeOrNew"

"取消搜索高亮显示(No light)
let g:WhichKeyDesc_NERDTreeOrNew_Highlight = "<leader>nl NoHighlight"
nmap <leader>nl :nohlsearch<CR>
"在当前目录新建文件夹
let g:WhichKeyDesc_NERDTreeOrNew_NewDir = "<leader>nd NewDir"
nmap <leader>nd <action>(NewDir)
"在当前目录新建类
let g:WhichKeyDesc_NERDTreeOrNew_NewClass = "<leader>nc NewClass"
nmap <leader>nc <action>(NewClass)


"========== p ==========
"从剪切板粘贴到下面行
let g:WhichKeyDesc_PasteClipboardDown = "<leader>p PasteClipboardDown"
nmap <leader>p "+p
"从剪切板粘贴到上面行
let g:WhichKeyDesc_PasteClipboardUp = "<leader>P PasteClipboardUp"
nmap <leader>P "+P
"在可视模式中:从剪切板粘贴到下面行
let g:WhichKeyDesc_PasteClipboardDown = "<leader>p PasteClipboardDown"
vmap <leader>p "+p
"在可视模式中:从剪切板粘贴到上面行
let g:WhichKeyDesc_PasteClipboardUp = "<leader>P PasteClipboardUp"
vmap <leader>P "+P


"========== r ==========
let g:WhichKeyDesc_RunOrRe = "<leader>r RunOrRe"

"运行当前编辑器中的文件或类(Shift + F10)
let g:WhichKeyDesc_RunOrRe_RunCalss = "<leader>ru RunClass"
nmap <leader>ru :action RunClass<CR>
"重新运行最近一次运行的程序或测试(Ctrl+Shift + F10)
let g:WhichKeyDesc_RunOrRe_ReRun = "<leader>rr ReRun"
nmap <leader>rr <action>(Rerun)
"重新运行最近一次运行的测试(Unit Tests)(Ctrl + Shift + F10)
let g:WhichKeyDesc_RunOrRe_ReRunTests = "<leader>rt ReRunTests"
nmap <leader>rt <action>(RerunTests)
"在代码中快速更改一个标识符的名称,并自动处理所有相关的引用(Shift + F6)
let g:WhichKeyDesc_RunOrRe_Rename = "<leader>rn Rename"
map <leader>rn <action>(RenameElement)

========= s ==========
let g:WhichKeyDesc_Show = "<leader>s Show"

"显示当前打开文件的文件结构弹出窗口,其中包含文件中的类、方法、字段等结构(Alt + 7)
let g:WhichKeyDesc_Show_FileStructure = "<leader>ss ShowFileStructure"
nmap <leader>ss <action>(FileStructurePopup)
"显示书签(Bookmarks)工具窗口,其中包含当前文件中设置的书签列表(Ctrl + F11)
let g:WhichKeyDesc_Show_Bookmarks = "<leader>sb ShowBookmarks"
nmap <leader>sb <action>(ShowBookmarks)
"用于显示方法或函数的参数信息(Ctrl + p)
let g:WhichKeyDesc_Show_ParameterInfo = "<leader>sp ShowParameterInfo"
nmap <leader>sp <action>(ParameterInfo)


"========= t ==========
"翻译
let g:WhichKeyDesc_Translate = "<leader>t Translate"
nmap <leader>t <action>($EditorTranslateAction)
vmap <leader>t <action>($EditorTranslateAction)


"========== w ==========
"""" 包含自定义宏,可能无法使用 """"
let g:WhichKeyDesc_Windows = "<leader>w Windows"

"取消分割窗口 并 隐藏所有编辑器窗口
let g:WhichKeyDesc_Windows_maximize = "<leader>wo maximize"
nmap <leader>wo <action>(UnsplitAll) \| <action>(HideAllWindows)
"在垂直方向上分割编辑器窗口,将一个编辑器窗口拆分为两个垂直排列的窗格(???)
let g:WhichKeyDesc_Windows_splitWindowVertically = "<leader>wl splitWindowVertically"
nmap <leader>wl <action>(Macro.SplitVertically)
"关闭当前窗口或分割窗格
let g:WhichKeyDesc_Windows_closeActiveWindow = "<leader>wc closeActiveWindow"
nmap <leader>wc <c-w>c
let g:WhichKeyDesc_Windows_HideActiveWindow = "<leader>wh HideActiveWindow"
nmap <leader>wh <Alt-6>


"========== y ==========
"将 "+ 简化为 <leader>
let g:WhichKeyDesc_CopyClipboard = "<leader>y CopyClipboard"
vmap <leader>y "+y
"将 "+ 简化为 <leader>
let g:WhichKeyDesc_CopyClipboard= "<leader>y CopyClipboard"
nmap <leader>y "+yy


"========== z ==========
let g:WhichKeyDesc_Zip = "<leader>z Zip"

"展开所有代码折叠区域(Ctrl + Shift + 加号键)
let g:WhichKeyDesc_Zip_unZipAll = "<leader>zo unZipAll"
nmap <leader>zo <action>(ExpandAllRegions)
"折叠所有代码折叠区域(Ctrl + Shift + 减号键)
let g:WhichKeyDesc_Zip_ZipAll = "<leader>zc ZipAll"
nmap <leader>zc <action>(CollapseAllRegions)




" ================================================================================================
" 🌸🌸🌸 NERDTree 🌸🌸🌸
" ================================================================================================
"<C-w-w>:在多个打开的编辑器窗口之间切换
"在目录中,按下 go 打开文件并保持光标在目录
"在目录中,按下 gi 以上下并排窗口形式打开文件(并关闭目录)
"光标在目录时,按Esc回到编辑器
"编辑器和目录间切换存在许多功能类似的快捷键,相似但不完全相同
"仅 打开/关闭 目录推荐使用<leader>wo 其次 Alt + 1

"按下 <leader>nn 将使焦点转移到 NERDTree 窗口
nnoremap <leader>nn :NERDTreeFocus<CR>
let g:WhichKeyDesc_NERDTreeOrNo_NERDTreeFocus = "<leader>nn NERDTreeFocus"
"按下 <C-n> 将打开 NERDTree 文件资源管理器
nnoremap <C-n> :NERDTree<CR>
"按下 <C-t> 将切换 NERDTree 文件资源管理器的显示状态,即打开或关闭 NERDTree
nnoremap <C-t> :NERDTreeToggle<CR>
"按下 <C-f> 将在 NERDTree 文件资源管理器中定位当前编辑文件所在的节点,并使其可见
nnoremap <C-f> :NERDTreeFind<CR>


noremap f :action AceAction<CR>

vim 学习
http://peiniwan.github.io/2024/04/44f1edd95334.html
作者
六月的雨
发布于
2024年4月6日
许可协议