Created
March 30, 2024 00:06
-
-
Save ivanfarevalo/96174660357a75dbfbf451410dc0fbc6 to your computer and use it in GitHub Desktop.
Pycharm vim plugin (ideavim) configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" .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 | |
" Found examples here:" | |
" https://github.com/JetBrains/ideavim/discussions/303" | |
" https://gist.github.com/AlexPl292/50a3ff4cef1badcbb23436b22cbd3cf4" | |
" https://github.com/citizenmatt/dotfiles/blob/master/ideavimrc" | |
" https://github.com/ddadon10/dotfiles/blob/trunk/.vimrc" | |
" Source your .vimrc | |
source ~/.vimrc | |
" ----- Vim Behavior ----- | |
"" Map jk to normal mode from insert mode | |
imap jk <Esc> | |
let mapleader="," | |
filetype plugin on " Enable filetype detection | |
filetype indent on " Enable filetype detection | |
" Remap enter to open a new line below the current line | |
nnoremap <Enter> o<Esc> | |
" Prevent vim from moving back one character after leaving insert mode | |
inoremap <silent> <Esc> <Esc>`^ | |
" Show relative numbers | |
set showmode | |
set number relativenumber | |
set showcmd | |
" Share clipboard with system | |
set clipboard^=unnamedplus,unnamed | |
" Standard Vim keybinding delegate to IntelliJ | |
map [[ <Action>(MethodUp) | |
map ]] <Action>(MethodDown) | |
map g; <Action>(JumpToLastChange) | |
map g, <Action>(JumpToNextChange) | |
" -- GoTo keybinding -- | |
map gd <Action>(GotoDeclaration) | |
map ge <Action>(GotoNextError) | |
map gi <Action>(GotoImplementation) | |
map gt <Action>(GotoTypeDeclaration) | |
map gT <Action>(GotoTest) | |
" Go to usage and declaration are the same action in IntelliJ | |
map gu <Action>(GotoDeclaration) | |
nmap gh <Action>(QuickJavaDoc) | |
nmap <leader>u <Action>(FindUsages) | |
" ----- Indentation ----- | |
set autoindent " Enable Auto indent | |
set smartindent | |
set shiftwidth=4 " For vim use only, pycharm settings overwrite these | |
set softtabstop=4 " For vim use only, pycharm settings overwrite these | |
"" -- Suggested options -- | |
" Show a few lines of context around the cursor. Note that this makes the | |
" text scroll if you mouse-click near the start or end of the window. | |
set scrolloff=5 | |
" Do incremental searching. | |
set incsearch | |
" Don't use Ex mode, use Q for formatting. | |
" map Q gq " Just use black formatter in pycharm | |
" Disable highlighting after search | |
nnoremap <leader><space> :nohlsearch<CR> | |
" --- Enable IdeaVim plugins https://jb.gg/ideavim-plugins | |
" Highlight copied text | |
Plug 'machakann/vim-highlightedyank' | |
" Commentary plugin - Use gc while highlighting, gcc for single line, gc5j for next 5 lines | |
Plug 'tpope/vim-commentary' | |
" Replace word under cursor griw (iw is the motion for "inner word"). | |
" Replace the next three lines with contents of register a, you would use "agrr3. | |
" Replace text in visual mode with contents of the clipboard +, "+gr. with clipboard setting above, just gr | |
Plug 'vim-scripts/ReplaceWithRegister' " [count][{reg}]gr{motion}, [count][{reg}]grr, {Visual}[{reg}]gr | |
""" Plugins -------------------------------- | |
set surround " ysiw( surround word with parenthesis, yss( surround sentence with parenthesis, also cs, ds. | |
"set multiple-cursors " Needs pycharm plugin. Too complicated to use. Use pycharm default option+Shift+click | |
set commentary " Use gc while highlighting, gcc for single line, gc5j for next 5 lines | |
set argtextobj " ia (inside an argument) aa (around an argument), ex: cia, dia, via + d or y | |
set easymotion " <leader><leader>w select word. Check below for remappings | |
"set textobj-entire " Operations on entire doc. Not very common use cmd+a | |
"set ReplaceWithRegister | |
set exchange " visual mode cx and then again to swap, cxx to swap whole lines, cxc to cancel | |
""" Plugin settings ------------------------- | |
let g:argtextobj_pairs="[:],(:),<:>" | |
" Find in current file view | |
map <leader>f <Plug>(easymotion-s) | |
" Find in whole file | |
map <leader>e <Plug>(easymotion-f) | |
""" Examples ------------------------- | |
"" -- Map IDE actions to IdeaVim -- https://jb.gg/abva4t | |
"" Map \r to the Reformat Code action | |
"map \r <Action>(ReformatCode) | |
"" Map <leader>d to start debug | |
"map <leader>d <Action>(Debug) | |
"" Map \b to toggle the breakpoint on the current line | |
"map \b <Action>(ToggleLineBreakpoint) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment