IDEA使用ideaVim, 配置自定义vim快捷键

.ideavimrc 配置文件
其实很简单,修改 ideavim 的配置文件 .ideavimrc 即可。默认情况下该文件并不存在,需要自行创建。macOS 或 Linux 下直接在当前用户目录下新建即可。(Windows 下应该也是在用户目录下新建配置文件,不过文件名应该是 _ideavimrc。)

macOS
在这里插入图片描述

wim 系统C:\Users\Administrator文件夹下创建_ideavimrc, 我这里用的是win系统
需要安装ideaVim插件
在这里插入图片描述

在这里插入图片描述

let mapleader=' '

set hlsearch
set incsearch
set ignorecase
set smartcase
set showmode
set number
set relativenumber
set scrolloff=3
set history=100000
set clipboard=unnamed

" clear the highlighted search result
" (清除高亮)
nnoremap <Leader>sc :nohlsearch<CR>

nnoremap <Leader>fs :w<CR>



" Quit normal mode
" (保存关闭)
nnoremap <Leader>q  :q<CR>
nnoremap <Leader>Q  :qa!<CR>

" Move half page faster
" (上下翻页)
nnoremap <Leader>d  <C-d>
nnoremap <Leader>u  <C-u>

" 快速进入vim模式
inoremap jj <Esc>
inoremap jk <Esc>
inoremap kk <Esc>

" Quit visual mode
vnoremap v <Esc>


" Redo
nnoremap U <C-r>

" 以下是自定义快捷键-----------------

" 复制单个单词
nnoremap <Leader>y ma"+yiw"ayiw

" 删除单个字符串并黏贴寄存器内容
nnoremap <Leader>v mbviw"ap

" ideavim内置快捷键alt+F1
nnoremap <Leader>m :action SelectIn<CR>

" ideavim内置快捷键control+E
nnoremap <Leader>e :action RecentFiles<CR>

" shift+h--zz(向上翻页)
nnoremap <Leader>h <S-h>zz

" shift+l--zz(向下翻页)
nnoremap <Leader>l <S-l>zz

" 以上是自定义快捷键-----------------

" quit ==> close current window
nnoremap <Leader>q <C-W>w

" Window operation
" (关于窗口操作)
nnoremap <Leader>ww <C-W>w
nnoremap <Leader>wd <C-W>c
nnoremap <Leader>wj <C-W>j
nnoremap <Leader>wk <C-W>k
nnoremap <Leader>wh <C-W>h
nnoremap <Leader>wl <C-W>l
nnoremap <Leader>ws <C-W>s
nnoremap <Leader>w- <C-W>s
nnoremap <Leader>wv <C-W>v
nnoremap <Leader>w\| <C-W>v

" Tab operation
" (切换标签)
nnoremap tn gt
nnoremap tp gT

" ==================================================
" Show all the provided actions via `:actionlist`
" ==================================================

" project search
"相当于IDEA的两次shift按钮
nnoremap <Leader>se :action SearchEverywhere<CR>

"查找用法
nnoremap <Leader>fu :action FindUsages<CR>

"打断点
nnoremap <Leader>bb :action ToggleLineBreakpoint<CR>

"查看所有断点
nnoremap <Leader>br :action ViewBreakpoints<CR>

"DUG启动
nnoremap <Leader>cd :action ChooseDebugConfiguration<CR>

"跳转到Action
nnoremap <Leader>ga :action GotoAction<CR>

"跳转到实体类
nnoremap <Leader>gc :action GotoClass<CR>

"跳转到声明
nnoremap <Leader>gd :action GotoDeclaration<CR>

"跳转到文件
nnoremap <Leader>gf :action GotoFile<CR>

"跳转到实现类
nnoremap <Leader>gi :action GotoImplementation<CR>

"跳转到测试类(没有则自动建立)
nnoremap <Leader>gt :action GotoTest<CR>

"显示当前文件路径
nnoremap <Leader>fp :action ShowFilePath<CR>

"激活maven窗口
"nnoremap <Leader>mv :action ActivateMavenProjectsToolWindow<CR>

"修改所有的关联名字
nnoremap <Leader>re :action RenameElement<CR>

"修改当前文件的文件名
nnoremap <Leader>rf :action RenameFile<CR>

"显示用法
nnoremap <Leader>su :action ShowUsages<CR>

"关闭活动显示板
nnoremap <Leader>tc :action CloseActiveTab<CR>

"以下是不常用

"打开命令管理器
nnoremap <Leader>tl Vy<CR>:action ActivateTerminalToolWindow<CR>
vnoremap <Leader>tl y<CR>:action ActivateTerminalToolWindow<CR>

" built in search looks better
" (查找字符串)
nnoremap / :action Find<CR>

" but preserve ideavim search
" (vim自带的搜索)
nnoremap <Leader>/ /

"添加注释
nnoremap <Leader>;; :action CommentByLineComment<CR>

"改变视图
nnoremap <Leader>cv :action ChangeView<CR>

"跳转到标致
nnoremap <Leader>gs :action GotoSymbol<CR>

"
nnoremap <Leader>ic :action InspectCode<CR>

nnoremap <Leader>oi :action OptimizeImports<CR>

nnoremap <Leader>pm :action ShowPopupMenu<CR>

"正常启动工程
nnoremap <Leader>rc :action ChooseRunConfiguration<CR>

查看ideaVim的内置快捷键 使用:进入vim模式 actionlist 查看所有快捷键

在这里插入图片描述
如上图黑光标按:再输入actionlist 查看所有ideavim的内置快捷键
在这里插入图片描述

快捷键查看

在这里插入图片描述

使用方式
nnoremap m :action SelectIn

发布了71 篇原创文章 · 获赞 3 · 访问量 8764

猜你喜欢

转载自blog.csdn.net/qq_40250122/article/details/102054921
今日推荐