Skip to content

Instantly share code, notes, and snippets.

@hungdh0x5e
Created February 24, 2023 04:47
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 hungdh0x5e/f82ad3a45af330720efc35a833e09c95 to your computer and use it in GitHub Desktop.
Save hungdh0x5e/f82ad3a45af330720efc35a833e09c95 to your computer and use it in GitHub Desktop.
Idea vimrc
" Plugin
set easymotion
set surround
set multiple-cursors
set commentary
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>, :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>
" Insert mode shortcut
inoremap <C-h> <Left>
inoremap <C-j> <Down>
inoremap <C-k> <Up>
inoremap <C-l> <Right>
inoremap <C-a> <Home>
inoremap <C-e> <End>
inoremap <C-d> <Delete>
" nnoremap L l
" nnoremap H h
" nnoremap l w
" nnoremap h b
" Quit insert mode
inoremap jj <Esc>
inoremap jk <Esc>
" Quit visual mode
vnoremap v <Esc>
" Move to the start of line
" nnoremap H ^
" Move to the end of line
" nnoremap L $
" Redo
nnoremap U <C-r>
" Yank to the end of line
nnoremap Y y$
" quit ==> close current window
nnoremap <Leader>q <C-W>w
" Window operation
nnoremap <Leader>ww <C-W>w
nnoremap <Leader>wd <C-W>c
" split horizontal
nnoremap <Leader>ws <C-W>s
nnoremap <Leader>w- <C-W>s
" split vertical
nnoremap <Leader>wv <C-W>v
nnoremap <Leader>w\| <C-W>v
" Switch window
nnoremap <C-j> <C-W>j
nnoremap <C-k> <C-W>k
nnoremap <C-h> <C-W>h
nnoremap <C-l> <C-W>l
nnoremap <Leader>wj <C-W>j
nnoremap <Leader>wk <C-W>k
nnoremap <Leader>wh <C-W>h
nnoremap <Leader>wl <C-W>l
" Tab operation
nnoremap tn gt
nnoremap tp gT
" Search will center on the line it's found in
nnoremap n nzzzv
nnoremap N Nzzzv
nnoremap # #zz
nnoremap * *zz
nnoremap g; g;zz
" Whatever you delete, make it go away
nnoremap c "_c
nnoremap C "_C
nnoremap x "_x
nnoremap X "_X
xnoremap c "_c
xnoremap C "_C
xnoremap x "_x
xnoremap X "_X
" Mapping Alt + jk to move line up or down
" Ref https://vim.fandom.com/wiki/Moving_lines_up_or_down
nnoremap <A-j> :m .+1<CR>==
nnoremap <A-k> :m .-2<CR>==
inoremap <A-j> <Esc>:m .+1<CR>==gi
inoremap <A-k> <Esc>:m .-2<CR>==gi
vnoremap <A-j> :m '>+1<CR>gv=gv
vnoremap <A-k> :m '<-2<CR>gv=gv
" ==================================================
" Show all the provided actions via `:actionlist`
" ==================================================
" built in search looks better
nnoremap / :action Find<CR>
" but preserve ideavim search
nnoremap <Leader>/ /
nnoremap <Leader>;; :action CommentByLineComment<CR>
nnoremap <Leader>bb :action ToggleLineBreakpoint<CR>
nnoremap <Leader>br :action ViewBreakpoints<CR>
nnoremap <Leader>cv :action ChangeView<CR>
nnoremap <Leader>cd :action ChooseDebugConfiguration<CR>
nnoremap ga :action GotoAction<CR>
nnoremap gd :action GotoDeclaration<CR>
nnoremap gf :action GotoFile<CR>
nnoremap gi :action GotoImplementation<CR>
nnoremap gs :action GotoSymbol<CR>
nnoremap gb :action GotoDatabaseObject<CR>
" project search
nnoremap <Leader>ps :action SearchEverywhere<CR>
nnoremap <Leader>pf :action GotoFile<CR>
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>gs :action GotoSymbol<CR>
nnoremap <Leader>gt :action GotoTest<CR>
nnoremap <Leader>gb :action GotoDatabaseObject<CR>
nnoremap <Leader>co :action CloseAllEditorsButActive<CR>
nnoremap <Leader>ot :action ActivateTerminalToolWindow<CR>
nnoremap fu :action FindUsages<CR>
nnoremap <Leader>fu :action FindUsages<CR>
nnoremap <Leader>fp :action ShowFilePath<CR>
nnoremap <Leader>ic :action InspectCode<CR>
nnoremap <Leader>mv :action ActivateMavenProjectsToolWindow<CR>
nnoremap <Leader>oi :action OptimizeImports<CR>
nnoremap <Leader>pm :action ShowPopupMenu<CR>
nnoremap <Leader>rc :action RunToCursor<CR>
nnoremap <Leader>rC :action ChooseRunConfiguration<CR>
nnoremap <Leader>re :action RenameElement<CR>
nnoremap <Leader>rf :action RenameFile<CR>
nnoremap <Leader>rr :action Rerun<CR>
nnoremap <Leader>rs :action Stop<CR>
nnoremap <Leader>se :action SearchEverywhere<CR>
nnoremap <Leader>su :action ShowUsages<CR>
nnoremap <Leader>tc :action CloseActiveTab<CR>
nnoremap <Leader>si :action StepInto<CR>
nnoremap <Leader>tb :action ToggleLineBreakpoint<CR>
nnoremap <Leader>tl Vy<CR>:action ActivateTerminalToolWindow<CR>
vnoremap <Leader>tl y<CR>:action ActivateTerminalToolWindow<CR>
nnoremap <Leader>? :action GotoAction<CR>
set ideajoin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment