IDEA配置

本文记录一下在IDEA中一些好用的配置:

将快捷键更改为VSCode keymap

  1. 安装VSCode keymap插件:

    2.打开File->Settings->Keymap,设置Keymap为VSCode:

IDEA返回上一次光标所在位置

Android Studio返回上一次光标所在位置

解决IDEA打开某个项目卡住(白屏)

其解决思路为删除IDEA在本地保存的该项目的状态文件;
其代价为需要重新导入该项目的各个模块。

参考资料:

  1. 解决 idea 打开某个项目卡住 (白屏)

解决IDEA无法指定compile output path的问题

如下图所示:

有时上图中的Compile output路径无法通过浏览目录指定,此时可以直接复制目录完整路径到该选项,如上图中的D:\Desktop\CS61B\out,应用后重启项目即可。

对ideaVim中的键进行重新映射

  1. C:\Users\user\目录下创建.ideavimrc文件。
  2. 在其中添加如下内容:
" basic settings
set ignorecase
set scrolloff=30
set history=200

set number
set relativenumber

set incsearch
set hlsearch
set keep-english-in-normal

" Plug
Plug 'preservim/nerdtree' 
set easymotion
set sneak
" nmap j j to Esc"
" imap jj <Esc>

" I like using H and L for beginning/end of line
" Have j and k navigate visual lines rather than logical ones
nmap H ^
nmap L $
nmap j gj
nmap k gk

" Yank to system clipboard"
set clipboard+=unnamed

" No Leader Keymaps
nmap gd <Action>(GotoDeclaration)
nmap ge <Action>(GotoNextError)
nmap gE <Action>(GotoPreviousError)
nmap gm <Action>(MethodDown)
nmap gM <Action>(MethodUp)

" Use <leader><Right> and <leader><Left> to locate Next/Previous Occurence
" nmap <leader><Right> <Action>(PreviousOccurrenceoftheWordatCaret)
" nmap <leader><Left> <Action>(NextOccurrenceoftheWordatCaret)
nmap <C-Right> <C-F3>
nmap <C-Left> <C-S-F3>

# set leader to space 
let mapleader=" " 

" Use <leader>l and <leader>h to switch tabs
nmap <leader>l gt
nmap <leader>h gT

" Use <leader>b to locate bracket
nmap <leader>b %

" Use <leader>q to close the current tab
nmap <leader>q :tabclose<CR>


" Use <leader>n to focus explorer 
nmap <leader>n :NERDTreeToggle<CR> 

PS:其中<Action>只能用于IDEA自带的actions。Plugins actions需要使用:

参考资料:

  1. vim - Intellij IdeaVim change keys - Stack Overflow
  2. dotfiles/.ideavimrc at master · fdietze/dotfiles · GitHub
  3. GitHub - AlexPl292/IdeaVim-EasyMotion: EasyMotion emulation plugin for IdeaVim
  4. let mapleader = “<Space>” not working! : vim
  5. Vim & IdeaVim shortcuts, keystroke combos and commands
  6. Vim keyboard shortcuts for project navigator / structure / tool window

IDEA插件推荐

  1. IdeaVimExtension:在切换到normal模式时,自动切换为英文输入(切换为美式键盘,不好用)
  2. IdeaVim-EasyMotion:用于配合<leader> <leader> w快速跳转
  3. IdeaVim-Sneak:行内快速跳转
  4. NERDTree:定位explorer并进行文件选择/重命名/新建等操作。NERDTree support · JetBrains/ideavim Wiki · GitHub
  5. Material Theme UI:IDEA界面主题美化
    其中NERDTree快捷键如下:

参考资料:NERDTree support · JetBrains/ideavim Wiki · GitHub

IDEA文件颜色配置

参考资料:

  1. File status highlights | IntelliJ IDEA Documentation

Maven依赖项

报错Dependency 'org.springframework.boot:spring-boot-starter-web:' not found
解决方案:Settings->Maven->Maven home directory->D:/Develop/Java/Maven/apache-maven-3.8.3,详细见参考资料

参考资料:

  1. 解决报错project ‘org.springframework.boot:spring-boot-starter-parent:1.5.9.RELEASE’ not found问题_叫我天真的博客-CSDN博客

创建文件时自动生成作者信息

参考资料:

  1. javadoc - Autocompletion of @author in Intellij - Stack Overflow

IDEA focus in sidebar

参考资料:

  1. Shortcut to toggle focus between project sidebar and editor? – IDEs Support (IntelliJ Platform) | JetBrains

IDEA将dotfiles/idea/.ideavimrc映射到C:\Users\A\.ideavimrc

打开cmd运行如下指令:

mklink C:\Users\A\.ideavimrc D:\Desktop\dotfiles\idea\.ideavimrc

IDEA将action映射到vim shortcuts

参考资料:

  1. IntelliJ IDEA Action List - Google Sheets
  2. IdeaVim actionlist · GitHub

IDEA在New window(新窗口) 中打开项目

Settings->Appearance & Behavior->System Settings

参考资料:

  1. Open, close, and move projects | IntelliJ IDEA Documentation