Skip to content

Instantly share code, notes, and snippets.

@chfle
Created June 26, 2021 07:06
Show Gist options
  • Save chfle/85f6a524a57b32b457ae947c4881d413 to your computer and use it in GitHub Desktop.
Save chfle/85f6a524a57b32b457ae947c4881d413 to your computer and use it in GitHub Desktop.
.ideavimrc
set relativenumber
set number
" https://github.com/JetBrains/ideavim/blob/master/doc/emulated-plugins.md
" https://youtrack.jetbrains.com/issue/VIM-1970
set set highlightedyank
" https://youtrack.jetbrains.com/issue/VIM-959
set ideamarks
" https://github.com/JetBrains/ideavim/wiki/%60ideajoin%60-examples
set ideajoin
" https://youtrack.jetbrains.com/issue/VIM-1521
set commentary
" dia daa cia caa
set argtextobj
" die dae cie cae
set textobj-entire
" https://youtrack.jetbrains.com/issue/VIM-1042
set NERDTree
" https://github.com/JetBrains/ideavim/wiki/Select-mode
" set selectmode-=template
" Mouseless Driven Development by Hadi Hariri https://www.youtube.com/watch?v=UH6YVv9js3s
" https://github.com/JetBrains/ideavim
" https://github.com/Valloric/dotfiles/blob/master/intellij/ideavimrc
" https://resources.jetbrains.com/storage/products/intellij-idea/docs/IntelliJIDEA_ReferenceCard.pdf
set surround
let mapleader = ","
" These are leader-based alternative shortcuts for actions whose corresponding
" idea shortcuts require hand-stretching combinations, function keys, Home or
" Insert.
"
" Shift + F6 in idea.
" Alt + R, then R (through the menu bar) also seems to work fine.
" map <Leader>r :action RenameElement<CR>
" Ctrl + F12 in idea.
" map <Leader>s Action(FileStructurePopup)
map <Leader>s <Action>(HideAllWindows)
map s <Action>(FileStructurePopup)
" Perhaps just use the Idea shortcut Ctrl-Alt-B
" Alt + N, then m (through the menu bar) also seems to work, but it is
" non-unique.
map <Leader>i <Action>(GotoImplementation)
map <Leader>m <Action>(GotoImplementation)
map <Leader>d <Action>(GotoImplementation)
" Jump to next/previous error, show error description
" https://stackoverflow.com/questions/13346245/keyboard-shortcut-to-display-error-in-intellij
map <Leader>e <Action>(ShowErrorDescription)
" Alt + F7 in idea.
" Find usages in file is Ctrl + F7.
" Alt + E, then F, then U (through the menu bar) also seems to work fine.
map <Leader>f <Action>(FindUsages)
" Alt + Insert in idea.
map <Leader>g <Action>(Generate)
" F12
map <Leader>w <Action>(JumpToLastWindow)
" Possibly redundant given "Run Anything" DoubleCtrl
map <Leader>r <Action>(ChooseRunConfiguration)
" These shortcuts mimic the default Idea action for one edition mode, using the
" Vim action for the other.
"
" Same as default IDEA action, but only in normal mode. Delete previous char
" in insert mode.
" See also Ctrl + Shift + H for method hierarchy, Ctrl + Alt + H for call
" hierarchy.
map <C-h> <Action>(TypeHierarchy)
" Same as default IDEA action, but only in insert mode. Enter block-visual
" mode in normal mode.
imap <C-v> <Esc><Action>($Paste)
" I like using space for jumping to the next error or issue
map <Space> <Action>(GotoNextError)
" The default C-o and C-i behaviours have certain inconsistencies with
" Vim which I can't quite pinpoint.
" I'm using the default IntelliJ behaviours instead.
map <C-o> <Action>(Back)
map <C-i> <Action>(Forward)
map g; <Action>(JumpToLastChange)
map g, <Action>(JumpToNextChange)
"
" Here are mappings about which I'm less sure.
" This is for going to related symbols. I can't find any effect in the community edition.
" map <Leader>g :action GotoRelated<CR>
" uppercase last inserted text. Perhpas just use gU`[ instead.
" map <Leader>u `[v`]~`]
" Can also use Ctrl-Shift-[
map <Leader>[ <Action>(EditorCodeBlockStart)
" Can also use Ctrl-Shift-]
map <Leader>] <Action>(EditorCodeBlockEnd)
" This is Ctrl-W in the default keymap, but we are using it for Vim.
" map <C-s> :action EditorSelectWord<CR> " somewhat unconfrotable to type
" map <C-d> :action EditorSelectWord<CR> " ditto
" better to use your two hands!
map <C-k> <Action>(EditorSelectWord)
" uppercase last inserted word
imap <C-l> <Esc>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment