Skip to content

Instantly share code, notes, and snippets.

@ggnam
Forked from lpld/.ideavimrc
Created December 27, 2022 01:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ggnam/0ca7d829b8e4a3006fec816bdc98a7a3 to your computer and use it in GitHub Desktop.
Save ggnam/0ca7d829b8e4a3006fec816bdc98a7a3 to your computer and use it in GitHub Desktop.
source ~/.vimrc
set visualbell
set noerrorbells
set surround
set relativenumber
" disable mappings from .vimrc
inoremap <C-U> <C-U>
inoremap <CR> <CR>
" in vim i use Tab to switch buffers
nnoremap <Tab> gt
nnoremap <S-Tab> gT
" similar to my vim Nerd tree mapping
nnoremap <Leader>n :action ActivateProjectToolWindow<CR>
" misc actions
nnoremap <Leader>z :action HideAllWindows<CR>
nnoremap <Leader>x :q<CR>
inoremap ;; <Esc>:action EditorCompleteStatement<CR>
" build and debug actions
nnoremap <Leader>Bp :action ViewBreakpoints<CR>
nnoremap <Leader>bP :action EditBreakpoint<CR>
nnoremap <Leader>bp :action ToggleLineBreakpoint<CR>
nnoremap <Leader>bB :action Compile<CR>
nnoremap <Leader>bb :action CompileDirty<CR>
nnoremap <Leader>bm :action Maven.ExecuteGoal<CR>
nnoremap <Leader>bM :action ActivateMavenProjectsToolWindow<CR>
nnoremap <Leader>bx :action RunClass<CR>
nnoremap <Leader>bX :action DebugClass<CR>
nnoremap <Leader>br :action Run<CR>
nnoremap <Leader>bR :action ChooseRunConfiguration<CR>
nnoremap <Leader>bd :action Debug<CR>
nnoremap <Leader>bD :action ChooseDebugConfiguration<CR>
nnoremap <Leader>bc :action CreateRunConfiguration<CR>
nnoremap <Leader>bC :action editRunConfigurations<CR>
" version control actions
nnoremap ]v :action VcsShowNextChangeMarker<CR>
nnoremap [v :action VcsShowPrevChangeMarker<CR>
nnoremap <Leader>vd :action VcsShowCurrentChangeMarker<CR>
nnoremap <Leader>vr :action Vcs.RollbackChangedLines<CR>
nnoremap <Leader>vu :action Vcs.UpdateProject<CR>
nnoremap <Leader>vp :action Vcs.Push<CR>
nnoremap <Leader>vc :action Vcs.QuickListPopupAction<CR>
nnoremap <Leader>vb :action Git.Branches<CR>
nnoremap <Leader>vv :action ActivateVersionControlToolWindow<CR>
nnoremap <Leader>va :set norelativenumber<CR>:action Annotate<CR>
" extract actions
nnoremap <Leader>ei :action ExtractInterface<CR>
nnoremap <Leader>es :action ExtractSuperclass<CR>
nnoremap <Leader>en :action ExtractClass<CR>
nnoremap <Leader>em :action ExtractMethod<CR>
vnoremap <Leader>em <Esc>gvhh:<bs><bs><bs><bs><bs>action VimVisualSwapSelections<cr>:action ExtractMethod<CR>
nnoremap <Leader>ev :action IntroduceVariable<CR>
vnoremap <Leader>ev <Esc>gvhh:<bs><bs><bs><bs><bs>action VimVisualSwapSelections<cr>:action IntroduceVariable<CR>
nnoremap <Leader>ef :action IntroduceField<CR>
vnoremap <Leader>ef <Esc>gvhh:<bs><bs><bs><bs><bs>action VimVisualSwapSelections<cr>:action IntroduceField<CR>
nnoremap <Leader>ep :action IntroduceParameter<CR>
vnoremap <Leader>ep <Esc>gvhh:<bs><bs><bs><bs><bs>action VimVisualSwapSelections<cr>:action IntroduceParameter<CR>
nnoremap <Leader>ec :action IntroduceConstant<CR>
vnoremap <Leader>ec <Esc>gvhh:<bs><bs><bs><bs><bs>action VimVisualSwapSelections<cr>:action IntroduceConstant<CR>
" refactoring actions
nnoremap <Leader>ri :action Inline<CR>
nnoremap <Leader>rr :action RenameElement<CR>i
nnoremap <Leader>rj :action MemberPushDown<CR>
nnoremap <Leader>rk :action MemberPullUp<CR>
nnoremap <Leader>rs :action ChangeSignature<CR>
nnoremap <Leader>rd :action SafeDelete<CR>
nnoremap <Leader>rm :action Move<CR>
nnoremap <Leader>rc :action CopyElement<CR>
" fix actions
nnoremap <Leader>ff :action ReformatCode<CR>
vnoremap <Leader>ff <Esc>gvhh:<bs><bs><bs><bs><bs>action VimVisualSwapSelections<cr>:action ReformatCode<CR>gv
nnoremap <Leader>fi :action OptimizeImports<CR>
nnoremap <Leader>fa :action ShowIntentionActions<CR><Esc>
" navigation ans search
nnoremap <Leader>su :action ShowUsages<CR>
nnoremap <Leader>sU :action FindUsages<CR>
nnoremap <Leader>si :action GotoImplementation<CR>
nnoremap <Leader>ss :action GotoSuperMethod<CR>
nnoremap <Leader>sd :action QuickImplementations<CR>
nnoremap <Leader>st :action GotoTypeDeclaration<CR>
nnoremap <Leader>sp :action Scala.TypeInfo<CR>:action ExpressionTypeInfo<CR>
vnoremap <Leader>sp <Esc>gvhh:<bs><bs><bs><bs><bs>action VimVisualSwapSelections<cr>:action Scala.TypeInfo<CR>:action ExpressionTypeInfo<CR>gv
nnoremap <Leader>sq :action Scala.GoToImplicit<CR>
vnoremap <Leader>sq <Esc>gvhh:<bs><bs><bs><bs><bs>action VimVisualSwapSelections<cr>:action Scala.GoToImplicit<CR>
nnoremap <Leader>sQ :action Scala.ShowImplicitParameters<CR>
nnoremap <Leader>sb :action ShowNavBar<CR>
nnoremap <Leader>sn :action SelectIn<CR>
nnoremap <Leader>se :action ShowErrorDescription<CR>
" ideavim regex are a bit buggy, cannot use regex from vimrc
nnoremap ]c /\\<trait\>\\\|\\<class\>\\\|\\<object\>\\\|\\<interface\>\\\|\\<enum\><CR>w:nohlsearch<CR>
nnoremap [c b?\\<trait\>\\\|\\<class\>\\\|\\<object\>\\\|\\<interface\>\\\|\\<enum\><CR>w:nohlsearch<CR>
nnoremap ]d /\\<def\><CR>w:nohlsearch<CR>
nnoremap [d b?\\<def\><CR>w:nohlsearch<CR>
nnoremap ]e :action GotoNextError<CR>
nnoremap [e :action GotoPreviousError<CR>
" hierarchy actions
nnoremap <Leader>hh :action TypeHierarchy<CR>
nnoremap <Leader>hm :action MethodHierarchy<CR>
nnoremap <Leader>hc :action CallHierarchy<CR>
nnoremap <Leader>hd :action ShowUmlDiagramPopup<CR>
" generate actions
nnoremap <Leader>ge :action GenerateEquals<CR>
nnoremap <Leader>gg :action GenerateGetter<CR>
nnoremap <Leader>gs :action GenerateSetter<CR>
nnoremap <Leader>ga :action GenerateGetterAndSetter<CR>
nnoremap <Leader>gc :action GenerateConstructor<CR>
nnoremap <Leader>gt :action Actions.ActionsPlugin.GenerateToString<CR>
nnoremap <Leader>go :action OverrideMethods<CR>
nnoremap <Leader>gi :action ImplementMethods<CR>
nnoremap <Leader>gd :action DelegateMethods<CR>
" bookmarks (a bit similar to vim marks)
nnoremap <Leader>m :action ToggleBookmarkWithMnemonic<CR>
nnoremap <Leader>' :action ShowBookmarks<CR>
nnoremap <Leader>` :action ShowBookmarks<CR>
nnoremap ]b :action GotoNextBookmark<CR>
nnoremap [b :action GotoPreviousBookmark<CR>
" fix visual selection bug
nnoremap gv gvh
" override settings from vimrc
vnoremap v v
vnoremap <C-v> <C-v>
" toggle relative numbers
nnoremap <F3> :set relativenumber!<CR>
" comment a line, similar to tpope/vim-commentary
nnoremap gcc :action CommentByLineComment<CR>
vnoremap gc :<bs><bs><bs><bs><bs>action VimVisualSwapSelections<cr>:action CommentByLineComment<CR>gv
nnoremap gcap vap:<bs><bs><bs><bs><bs>action VimVisualSwapSelections<cr>:action CommentByLineComment<CR>gv
" lombok
nnoremap <Leader>ld :action defaultLombokData<CR>
nnoremap <Leader>le :action defaultLombokEqualsAndHashcode<CR>
nnoremap <Leader>lg :action defaultLombokGetter<CR>
nnoremap <Leader>ll :action defaultLombokLogger<CR>
nnoremap <Leader>ls :action defaultLombokSetter<CR>
nnoremap <Leader>lt :action defaultLombokToString<CR>
nnoremap <Leader>lr ?\\<class\>\\\|\\<enum\><CR>:nohlsearch<CR>O@lombok.RequiredArgsConstructor<Esc>
" this still doesn't work :(
nnoremap <Leader>/ /\\< \>
nnoremap <Leader>? ?\\< \>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment