|
|
|
" see more https://blog.einverne.info/post/2020/12/my-idea-vimrc-config.html
|
|
|
|
" enable plugin
|
|
|
|
set easymotion
|
|
|
|
set surround
|
|
|
|
set multiple-cursors
|
|
|
|
set nu
|
|
|
|
" 相对行号
|
|
|
|
set rnu
|
|
|
|
" set clipboard=unnamed,autoselect
|
|
|
|
|
|
|
|
" Use comma as leader key, there are other modifier keys in this config,
|
|
|
|
" like space, \, t(in normal mode for toggle something),
|
|
|
|
" g(in normal mode for goto somewhere)
|
|
|
|
let mapleader = ","
|
|
|
|
let g:mapleader = ","
|
|
|
|
|
|
|
|
" https://github.com/JetBrains/ideavim/blob/master/doc/set-commands.md
|
|
|
|
set hlsearch
|
|
|
|
set incsearch
|
|
|
|
set scrolloff=5
|
|
|
|
set ignorecase
|
|
|
|
set smartcase
|
|
|
|
" 当前模式
|
|
|
|
set showmode
|
|
|
|
set history=10000
|
|
|
|
|
|
|
|
" source ~/.vimrc
|
|
|
|
|
|
|
|
noremap <Leader>r <ESC>:source ~/.ideavimrc<cr>
|
|
|
|
|
|
|
|
" general
|
|
|
|
nnoremap <Leader>f :<C-u>action ReformatCode<CR>
|
|
|
|
nnoremap <Leader>g :<C-u>action FindInPath<CR>
|
|
|
|
vnoremap <Leader>g :<C-u>action FindInPath<CR>
|
|
|
|
nnoremap <Leader>r :<C-u>action RenameElement<CR>
|
|
|
|
nnoremap <Leader>o :<C-u>action RecentProjectListGroup<CR>
|
|
|
|
nnoremap <Leader>d :<C-u>action ChooseDebugConfiguration<CR>
|
|
|
|
nnoremap <Leader>w :<C-u>action CloseAllEditorsButActive<CR>
|
|
|
|
|
|
|
|
" screen management
|
|
|
|
" Vertical split screen
|
|
|
|
nnoremap <Leader>\ <C-w>v
|
|
|
|
nnoremap <Leader>- <C-w>s
|
|
|
|
nnoremap <C-h> <C-w>h
|
|
|
|
nnoremap <C-l> <C-w>l
|
|
|
|
nnoremap <C-j> <C-w>j
|
|
|
|
nnoremap <C-k> <C-w>k
|
|
|
|
|
|
|
|
" Redo
|
|
|
|
nnoremap U <C-r>
|
|
|
|
|
|
|
|
" go to somewhere (g in normal mode for goto somewhere)
|
|
|
|
nnoremap ga :<C-u>action GotoAction<CR>
|
|
|
|
nnoremap gc :<C-u>action GotoClass<CR>
|
|
|
|
nnoremap gd :<C-u>action GotoDeclaration<CR>
|
|
|
|
nnoremap gs :<C-u>action GotoSuperMethod<CR>
|
|
|
|
nnoremap gi :<C-u>action GotoImplementation<CR>
|
|
|
|
nnoremap gf :<C-u>action GotoFile<CR>
|
|
|
|
nnoremap gm :<C-u>action GotoSymbol<CR>
|
|
|
|
nnoremap gl :<C-u>action JumpToLastChange<CR>
|
|
|
|
nnoremap gu :<C-u>action ShowUsages<CR>
|
|
|
|
nnoremap gt :<C-u>action GotoTest<CR>
|
|
|
|
nnoremap gp :<C-u>action FindInPath<CR>
|
|
|
|
nnoremap gr :<C-u>action RecentFiles<CR>
|
|
|
|
" cmd + [ and cmd + ]
|
|
|
|
" nnoremap gh :<C-u>action Back<CR>
|
|
|
|
" nnoremap gl :<C-u>action Forward<CR>
|
|
|
|
|
|
|
|
" code editing
|
|
|
|
nnoremap == :<C-u>action ReformatCode<CR>
|
|
|
|
vnoremap == :<C-u>action ReformatCode<CR>
|
|
|
|
" nnoremap \i :<C-u>action OptimizeImports<CR>
|
|
|
|
" vnoremap \i :<C-u>action OptimizeImports<CR>
|
|
|
|
" nnoremap \r :<C-u>action RenameElement<CR>
|
|
|
|
nnoremap q :<C-u>action ShowIntentionActions<CR>
|
|
|
|
nnoremap cc :<C-u>action CommentByLineComment<CR>
|
|
|
|
vnoremap cc :<C-u>action CommentByLineComment<CR>
|
|
|
|
|
|
|
|
" show information
|
|
|
|
nnoremap <C-I> :<C-u>action QuickJavaDoc<CR>
|
|
|
|
|
|
|
|
" 在 Tab 间切换 Alt/Option + h/l
|
|
|
|
nnoremap <space>h gT
|
|
|
|
nnoremap <space>l gt
|
|
|
|
|
|
|
|
" Ctrl+Shift+Tab Ctrl+Tab
|
|
|
|
nnoremap <c-s-tab> gT
|
|
|
|
nnoremap <c-tab> gt
|
|
|
|
|
|
|
|
" clear the search buffer when hitting return
|
|
|
|
nnoremap <space><cr> :nohlsearch<cr>
|
|
|
|
|
|
|
|
" show information
|
|
|
|
nnoremap <C-I> :<C-u>action QuickJavaDoc<CR>
|
|
|
|
|
|
|
|
" options
|
|
|
|
nnoremap cow :action EditorToggleUseSoftWraps<cr>
|
|
|
|
nnoremap col :action EditorToggleShowWhitespaces<cr>
|
|
|
|
nnoremap ta :action Annotate<cr>
|
|
|
|
nnoremap tb :action ToggleLineBreakpoint<cr>
|
|
|
|
nnoremap tm :action ToggleBookmark<cr>
|
|
|
|
nnoremap tp :action ActivateProjectToolWindow<CR>
|
|
|
|
|
|
|
|
" actions
|
|
|
|
nnoremap <space>q :action CloseContent<cr>
|
|
|
|
nnoremap <space>w :action CloseContent<cr>
|
|
|
|
nnoremap <space>Q :action ReopenClosedTab<cr>
|
|
|
|
nnoremap <space>\ :action VimFilePrevious<cr>
|
|
|
|
nnoremap <space>e :action SearchEverywhere<cr>
|
|
|
|
nnoremap <space>E :action Switcher<cr>
|
|
|
|
nnoremap <space>t :action FileStructurePopup<cr>
|
|
|
|
nnoremap <space>T :action GotoSymbol<cr>
|
|
|
|
nnoremap <space>a :action Annotate<cr>
|
|
|
|
nnoremap <space>b :action ToggleLineBreakpoint<cr>
|
|
|
|
nnoremap <space>u :action FindUsages<cr>
|
|
|
|
nnoremap <space>k :action HighlightUsagesInFile<cr>
|
|
|
|
|
|
|
|
" Run and debug
|
|
|
|
nnoremap \r :action RunClass<cr>
|
|
|
|
nnoremap \R :action Run<cr>
|
|
|
|
nnoremap \d :action DebugClass<cr>
|
|
|
|
nnoremap \D :action Debug<cr>
|
|
|
|
nnoremap \c :action CheckStyleCurrentFileAction<cr>
|
|
|
|
|
|
|
|
" unimpaired mappings
|
|
|
|
nnoremap [<space> O<esc>j
|
|
|
|
nnoremap ]<space> o<esc>k
|
|
|
|
nnoremap [q :action PreviousOccurrence<cr>
|
|
|
|
nnoremap ]q :action NextOccurrence<cr>
|
|
|
|
nnoremap [m :action MethodUp<cr>
|
|
|
|
nnoremap ]m :action MethodDown<cr>
|
|
|
|
nnoremap [c :action VcsShowPrevChangeMarker<cr>
|
|
|
|
nnoremap ]c :action VcsShowNextChangeMarker<cr>
|
|
|
|
|
|
|
|
|
|
|
|
" built-in navigation to navigated items works better
|
|
|
|
" nnoremap <c-o> :action Back<cr>
|
|
|
|
" nnoremap <c-i> :action Forward<cr>
|
|
|
|
" but preserve ideavim defaults
|
|
|
|
nnoremap g<c-o> <c-o>
|
|
|
|
nnoremap g<c-i> <c-i>
|
|
|
|
|
|
|
|
" built in search looks better
|
|
|
|
" nnoremap / :action Find<cr>
|
|
|
|
" but preserve ideavim search
|
|
|
|
nnoremap g/ <ESC>:action FindInPath<cr>
|
|
|
|
noremap ' <ESC>:action Replace<cr>
|
|
|
|
noremap g' <ESC>:action ReplaceInPath<cr>
|
|
|
|
|
|
|
|
nnoremap [[ :action MethodUp<cr>
|
|
|
|
nnoremap ]] :action MethodDown<cr>
|
|
|
|
|
|
|
|
" easy motion"
|
|
|
|
map , <Plug>(easymotion-prefix)
|
|
|
|
|
|
|
|
"Turn on case insensitive feature
|
|
|
|
let g:EasyMotion_smartcase = 1
|
|
|
|
"Use upper target labels and type as a lower case
|
|
|
|
let g:EasyMotion_use_upper = 0
|
|
|
|
|
|
|
|
" move to character
|
|
|
|
nmap f <Plug>(easymotion-s2)
|
|
|
|
xmap f <Plug>(easymotion-s2)
|
|
|
|
omap f <Plug>(easymotion-s2)
|
|
|
|
" move to word
|
|
|
|
nmap F <Plug>(easymotion-bd-w)
|
|
|
|
xmap F <Plug>(easymotion-bd-w)
|
|
|
|
omap F <Plug>(easymotion-bd-w)
|
|
|
|
" move to line
|
|
|
|
" nmap gl <Plug>(easymotion-bd-jk)
|
|
|
|
" xmap gl <Plug>(easymotion-bd-jk)
|
|
|
|
" omap gl <Plug>(easymotion-bd-jk)
|
|
|
|
|
|
|
|
" acejump"
|
|
|
|
" Press `f` to activate AceJump
|
|
|
|
nnoremap f :<C-u>action AceAction<CR>
|
|
|
|
" Press `F` to activate Target Mode
|
|
|
|
" 在 Target 模式下会跳转到目标,并选中目标整个Word"
|
|
|
|
nnoremap F :<C-u>action AceTargetAction<CR>
|
|
|
|
" Press `g` to activate Line Mode
|
|
|
|
" nnoremap g :action AceLineAction<CR>
|
|
|
|
|
|
|
|
" kick intellij commands
|
|
|
|
" nnoremap R :<C-u>action ChooseRunConfiguration<CR>
|
|
|
|
nnoremap D :<C-u>action ChooseRunConfiguration<CR>
|
|
|
|
" nnoremap F5 :<C-u>action StepInto<CR>
|
|
|
|
" nnoremap F6 :<C-u>action StepOver<CR>
|
|
|
|
" nnoremap F8 :<C-u>action Resume<CR>
|
|
|
|
|
|
|
|
" window
|
|
|
|
nnoremap s; :<C-u>action CloseActiveTab<CR>
|
|
|
|
nnoremap so :<C-u>action MoveEditorToOppositeTabGroup<CR>
|
|
|
|
|
|
|
|
" multiple cursors
|
|
|
|
" <A-n>, <A-n>, <A-p>, g<A-n>
|