Skip to content

Instantly share code, notes, and snippets.

@jantobola
Last active February 4, 2025 14:01
Show Gist options
  • Save jantobola/51fd37f0812d9f3ed9587802944adfe8 to your computer and use it in GitHub Desktop.
Save jantobola/51fd37f0812d9f3ed9587802944adfe8 to your computer and use it in GitHub Desktop.
IdeaVim Keymaps
" .ideavimrc is a configuration file for IdeaVim plugin. It uses
" the same commands as the original .vimrc configuration.
" You can find a list of commands here: https://jb.gg/h38q75
" Find more examples here: https://jb.gg/share-ideavimrc
let mapleader = " "
set peekaboo
set scrolloff=5
set hlsearch
set which-key
set easymotion
set notimeout
" Do incremental searching.
set incsearch
" Don't use Ex mode, use Q for formatting.
map Q gq
" --- Enable IdeaVim plugins https://jb.gg/ideavim-plugins
let g:qs_highlight_on_keys = ['f', 'F', 't', 'T']
let g:qs_disable_for_diffs = 1
let g:WhichKey_ShowVimActions = "false"
let g:WhichKey_ShowTypedSequence = "true"
let g:WhichKeyDesc_j_prefix = "<leader>j ace jump"
" Highlight copied text
Plug 'machakann/vim-highlightedyank'
" Commentary plugin
Plug 'tpope/vim-commentary'
Plug 'justinmk/vim-sneak'
set ignorecase
set idearefactormode=keep
set quickscope
set clipboard+=unnamed
packadd matchit
map <Leader>xx :noh<CR>
inoremap <C-CR> <Left><CR><CR><Up><Tab>
imap <C-k> <Action>(EditorStartNewLine)
imap <C-j> <Action>(EditorStartNewLineBefore)
" This would work in normal vim, idea adds proper code padding
"imap <C-L> <Esc>A<CR>
"imap <C-O> <Esc>^a<CR><Esc><Up>a
set clipboard+=unnamed
noremap Y "*y
noremap <Bslash> ;
"noremap ; l
"noremap o k
"noremap l j
"noremap k h
"noremap L o
noremap j k
noremap k j
" ------- Navigation & Code completion -------
if has("linux")
map <A-k> <Action>(EditorDown)
imap <A-k> <Action>(EditorDown)
map <A-j> <Action>(EditorUp)
imap <A-j> <Action>(EditorUp)
map <A-D-h> <Action>(Back)
imap <A-D-h> <Action>(Back)
map <A-D-l> <Action>(Forward)
imap <A-D-l> <Action>(Forward)
map <A-S-CR> <Action>(EditorCompleteStatement)
imap <A-S-CR> <Action>(EditorCompleteStatement)
" duplicate
map <A-d> ^y$o<Esc>p0
imap <A-d> <Esc>^y$o<Esc>p0i
" move line up/down
map <D-S-k> ddp
imap <D-S-k> <Esc>ddpi
map <D-S-j> ddjP
imap <D-S-j> <Esc>ddjPi
vmap <D-S-j> <Action>(MoveLineUp)
vmap <D-S-k> <Action>(MoveLineDown)
map <A-S-j> <Action>(MoveStatementUp)
map <A-S-k> <Action>(MoveStatementDown)
imap <A-S-j> <Action>(MoveStatementUp)
imap <A-S-k> <Action>(MoveStatementDown)
map <D-j> <Action>(MethodUp)
imap <D-j> <Action>(MethodUp)
map <D-k> <Action>(MethodDown)
imap <D-k> <Action>(MethodDown)
"" Shift tab to next pane or create pane
map <C-D-l> <Action>(TabShiftActions.ShiftRight)
map <C-D-h> <Action>(TabShiftActions.ShiftLeft)
map <C-D-j> <Action>(TabShiftActions.ShiftUp)
map <C-D-k> <Action>(TabShiftActions.ShiftDown)
"" Arrow version
map <C-D-Right> <Action>(TabShiftActions.ShiftRight)
map <C-D-Left> <Action>(TabShiftActions.ShiftLeft)
map <C-D-Up> <Action>(TabShiftActions.ShiftUp)
map <C-D-Down> <Action>(TabShiftActions.ShiftDown)
map <A-T> <Action>(Vcs.UpdateProject)
map <D-CR> <Action>(ShowIntentionActions)
imap <D-CR> <Action>(ShowIntentionActions)
imap <A-y> () {}<Esc>i<CR><Esc>j$hhi
imap <A-u> (
imap <A-o> )
imap <A-S-u> {
imap <A-S-o> }
imap <A-m> <
imap <A-.> >
imap <A-S-m> [
imap <A-S-.> ]
imap <A-h> <Left>
imap <A-l> <Right>
imap <A-j> <Up>
imap <A-k> <Down>
map <A-h> ^
map <A-l> $
map <A-j> 5j
map <A-k> 5k
map <A-S-h> b
map <A-S-l> e
end
if has("mac")
map <D-k> <Action>(EditorDown)
imap <D-k> <Action>(EditorDown)
map <D-j> <Action>(EditorUp)
imap <D-j> <Action>(EditorUp)
map <D-M-h> <Action>(Back)
imap <D-M-h> <Action>(Back)
map <D-M-l> <Action>(Forward)
imap <D-M-l> <Action>(Forward)
map <D-S-CR> <Action>(EditorCompleteStatement)
imap <D-S-CR> <Action>(EditorCompleteStatement)
" duplicate
map <D-d> ^y$o<Esc>p0
imap <D-d> <Esc>^y$o<Esc>p0i
" move line up/down
map <M-S-k> ddp
imap <M-S-k> <Esc>ddpi
map <M-S-j> ddjP
imap <M-S-j> <Esc>ddjPi
vmap <M-S-j> <Action>(MoveLineUp)
vmap <M-S-k> <Action>(MoveLineDown)
map <D-S-j> <Action>(MoveStatementUp)
map <D-S-k> <Action>(MoveStatementDown)
imap <D-S-j> <Action>(MoveStatementUp)
imap <D-S-k> <Action>(MoveStatementDown)
map <M-j> <Action>(MethodUp)
imap <M-j> <Action>(MethodUp)
map <M-k> <Action>(MethodDown)
imap <M-k> <Action>(MethodDown)
"" Shift tab to next pane or create pane
map <C-M-l> <Action>(TabShiftActions.ShiftRight)
map <C-M-h> <Action>(TabShiftActions.ShiftLeft)
map <C-M-j> <Action>(TabShiftActions.ShiftUp)
map <C-M-k> <Action>(TabShiftActions.ShiftDown)
"" Arrow version
map <C-M-Right> <Action>(TabShiftActions.ShiftRight)
map <C-M-Left> <Action>(TabShiftActions.ShiftLeft)
map <C-M-Up> <Action>(TabShiftActions.ShiftUp)
map <C-M-Down> <Action>(TabShiftActions.ShiftDown)
map <D-T> <Action>(Vcs.UpdateProject)
map <M-CR> <Action>(ShowIntentionActions)
imap <M-CR> <Action>(ShowIntentionActions)
imap <D-y> () {}<Esc>i<CR><Esc>j$hhi
imap <D-u> (
imap <D-o> )
imap <D-S-u> {
imap <D-S-o> }
imap <D-m> <
imap <D-.> >
imap <D-S-m> [
imap <D-S-.> ]
imap <D-Left> <Left>
imap <D-Right> <Right>
imap <D-j> <Up>
imap <D-k> <Down>
" cmd + h is a system keymap, which must be remapped with skhd
map <D-Left> _
map <D-Right> $
map <D-j> 5j
map <D-k> 5k
map <D-S-h> b
map <D-S-l> e
end
map <leader><leader> <Action>(SelectInProjectView)
"" Ace Jump
map <leader>j <Plug>(easymotion-s)
" This enables to paste only from buffer 0, which is used by default only for yank operation
map <C-p> :normal! "0p<CR>
imap <C-p> <Esc>:normal! "0p<CR>a
map <C-S-p> :normal! "+p<CR>
imap <C-S-p> <Esc>:normal! "+p<CR>a
map <C-Space> <Action>(CodeCompletion)
imap <C-Space> <Action>(CodeCompletion)
map <C-S-Space> <Action>(SmartTypeCompletion)
imap <C-S-Space> <Action>(SmartTypeCompletion)
"" Tabs
"" Move between panes
map <C-h> <C-W>h
map <C-l> <C-W>l
map <C-k> <C-W>j
map <C-j> <C-W>k
"" Tab switching
map <C-S-h> <Action>(PreviousTab)
map <C-S-l> <Action>(NextTab)
map <C-S-Left> <Action>(PreviousTab)
map <C-S-Right> <Action>(NextTab)
"" Pane resizing
map <C-Left> <Action>(StretchSplitToLeft)
map <C-Right> <Action>(StretchSplitToRight)
map <C-Up> <Action>(StretchSplitToTop)
map <C-Down> <Action>(StretchSplitToBottom)
" ------- (r) Refactoring -------
let g:WhichKeyDesc_r_prefix = "<leader>r refactoring"
let g:WhichKeyDesc_s_prefix = "<leader>s string manipulation"
map <leader>roi <Action>(OptimizeImports)
map <leader>rr <Action>(ReformatCode)
map <leader>red <Action>(IntroduceActionsGroup)
map <leader>ref <Action>(ExtractFunction)
map <leader>rev <Action>(IntroduceVariable)
map <leader>rs <Action>(SurroundWith)
map <leader>rg <Action>(Generate)
map <leader>rmo <Action>(OverrideMethods)
map <leader>rmi <Action>(ImplementMethods)
map <leader>rmd <Action>(DelegateMethods)
map <leader>rld <Action>(ExternalSystem.ProjectRefreshAction)
map <leader>str <Action>(osmedile.intellij.stringmanip.PopupChoiceAction)
map <leader>ra <Action>(ShowIntentionActions)
map <leader>rnm <Action>(RenameElement)
" ------- (p) Project -------
let g:WhichKeyDesc_p_prefix = "<leader>p project"
map <leader>pc <Action>(CompileFile)
map <leader>pb <Action>(CompileDirty)
map <leader>prb <Action>(CompileProject)
" ------- (d) Debugging -------
let g:WhichKeyDesc_d_prefix = "<leader>d debugging"
let g:WhichKeyDesc_D_prefix = "<leader>D debugging"
map <leader>dd <Action>(DebugClass)
map <leader>DD <Action>(ChooseDebugConfiguration)
map <leader>db <Action>(ToggleLineBreakpoint)
map <leader>dee <Action>(QuickEvaluateExpression)
map <leader>ded <Action>(EvaluateExpression)
map <leader>dw <Action>(Debugger.AddToWatch)
map <leader>diw <Action>(Debugger.AddInlineWatch)
map <leader>dtc <Action>(RunToCursor)
map <leader>dr <Action>(Resume)
map <leader>dsl <Action>(StepOver)
map <leader>dsi <Action>(StepInto)
map <leader>dso <Action>(StepOut)
map <leader>dx <Action>(Stop)
map <leader>dlb <Action>(ViewBreakpoints)
map <leader>dcb <Action>(Debugger.RemoveAllBreakpointsInFile)
" ------- (R) Run -------
let g:WhichKeyDesc_R_prefix = "<leader>R Run"
map <leader>Rr <Action>(RunClass)
map <leader>Ra <Action>(RunAnything)
map <leader>Rg <Action>(Gradle.ExecuteTask)
map <leader>RR <Action>(ChooseRunConfiguration)
" ------- (w) Window management -------
let g:WhichKeyDesc_w_prefix = "<leader>w window/pane management"
map <leader>wco <Action>(ChangeSplitOrientation)
map <leader>wus <Action>(Unsplit)
map <leader>ws <Action>(SplitVertically)
map <leader>whs <Action>(SplitHorizontally)
map <leader>wp <Action>(PinActiveTabToggle)
map <leader>wx <Action>(CloseContent)
map <leader>wax <Action>(CloseAllEditors)
" ------- (g) Go To -------
let g:WhichKeyDesc_g_prefix = "<leader>g go to"
map <leader>gd <Action>(GotoDeclaration)
map <leader>gu <Action>(GotoDeclaration)
map <leader>gi <Action>(GotoImplementation)
map <leader>gs <Action>(GotoSuperMethod)
map <leader>ge <Action>(GotoUrlAction)
map <leader>gr <Action>(RecentFiles)
map <leader>gc <Action>(GotoClass)
map <leader>go <Action>(GotoSymbol)
map <leader>gf <Action>(GotoFile)
map <leader>gge <Action>(SearchEverywhere)
map <leader>gga <Action>(GotoAction)
map <leader>g. <Action>(SelectInProjectView)
map <leader>gm <Action>(ShowBookmarks)
if has("linux")
map <A-S-A> <Action>(GotoAction)
map <A-E> <Action>(RecentFiles)
end
if has("mac")
map <D-S-A> <Action>(GotoAction)
map <D-E> <Action>(RecentFiles)
end
" ------- (f) Find -------
let g:WhichKeyDesc_f_prefix = "<leader>f find"
map <leader>ff <Action>(FindInPath)
map <leader>fu <Action>(FindUsages)
" ------- (m) Bookmarks -------
let g:WhichKeyDesc_m_prefix = "<leader>m bookmarks"
map <leader>mm <Action>(ToggleBookmark)<Action>(EditBookmark)
map <leader>mn <Action>(ToggleBookmarkWithMnemonic)
map <leader>mb <Action>(ToggleBookmark)
map <leader>md <Action>(ToggleBookmark)
map <leader>mt <Action>(ShowTypeBookmarks)
map <leader>ml <Action>(ShowBookmarks)
map <leader>mr <Action>(EditBookmark)
" ------- (n) Next -------
let g:WhichKeyDesc_n_prefix = "<leader>n jump to next"
map <leader>ne <Action>(GotoNextError)
map <leader>nE <Action>(GotoPreviousError)
" ------- (c) Code Context -------
let g:WhichKeyDesc_c_prefix = "<leader>c code context"
map <leader>cp <Action>(ParameterInfo)
map <leader>ct <Action>(ExpressionTypeInfo)
map <leader>cd <Action>(QuickJavaDoc)
map <leader>ci <Action>(ShowErrorDescription)
map <leader>cs <Action>(FileStructurePopup)
if has("linux")
map <A-F1> <Action>(ShowErrorDescription)
map <A-P> <Action>(ParameterInfo)
imap <A-P> <Action>(ParameterInfo)
end
if has("mac")
map <D-F1> <Action>(ShowErrorDescription)
map <D-P> <Action>(ParameterInfo)
imap <D-P> <Action>(ParameterInfo)
end
" ------- (x) Hide -------
let g:WhichKeyDesc_x_prefix = "<leader>x hide / suppress"
map <leader>xn <Action>(ClearAllNotifications)
map <leader>xab <Action>(Debugger.RemoveAllBreakpointsInFile)
" ------- (u) Update -------
let g:WhichKeyDesc_u_prefix = "<leader>u update"
map <leader>ug <Action>(Vcs.UpdateProject)
map <leader>uiv <Action>(IdeaVim.ReloadVimRc.reload)
map <leader>up <Action>(ExternalSystem.RefreshAllProjects)
" ------- (\) Diff -------
let g:WhichKeyDesc_bslash_prefix = "<leader><Bslash> diff
map <C-\> <Action>(Diff.FocusOppositePane)
map <leader><Bslash>s <Action>(Diff.ShowSettingsPopup)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment