Skip to content

Instantly share code, notes, and snippets.

@ericvanjohnson
Created May 30, 2024 18:20
Show Gist options
  • Save ericvanjohnson/9976e3e8a28a5af544e37da8d2e1e035 to your computer and use it in GitHub Desktop.
Save ericvanjohnson/9976e3e8a28a5af544e37da8d2e1e035 to your computer and use it in GitHub Desktop.
PhpStorm IdeaVim Customized file
" To get a list of Actions, run `:actionlist `
" Set the leader key to <SPACE>
let mapleader = "\<SPACE>"
set ignorecase smartcase
set NERDTree
set hlsearch
set showmode
set scrolloff=5
set history=1000
set surround
set incsearch
set relativenumber
set number
set smartcase
set noerrorbells
set easymotion
set commentary
set ideajoin
set exchange
set multiplecursor
set sneak
set which-key
set timeoutlen=8000
" clear the search buffer
nnoremap <Leader>h :nohlsearch<cr>
" To copy text to the end-of-line, press Y.
" This mapping sets up Y to be consistent with
" the C and D operators, which act from the cursor
" to the end of the line. The default behavior of Y
" is to yank the whole line.
nnoremap Y y$
" Shortcut for escape
imap jj <Esc>
imap jk <Esc>
" When in normal mode and I hit Enter,
" format and save the file, please
nmap <CR> :action ReformatCode<CR> :write<CR>
" Quick window navigation
map <C-J> <C-W>j
map <C-K> <C-W>k
map <C-L> <C-W>l
map <C-H> <C-W>h
" Shortcut for copying to/from System Clipboard
vmap <Leader>y "+y
vmap <Leader>d "+d
nmap <Leader>P "+P
" Greatest remap EVER!!
" Let me explain: this remap while in visual mode
" will delete what is currently highlighted and replace it
" with what is in the register, BUT it will YANK (delete) it
" to a VOID register. Meaning I still have what I originally had
" when I pasted. I don't lose the previous thing I YANKED!
vnoremap <leader>p "_dP
" Ctrl-P simulation
nnoremap <C-p> :action GotoFile<CR>
" Splitting Windows
nmap <Leader>V :vsplit<CR>
nmap <Leader>H :split<CR>
nmap <Leader>\ :vsplit<CR>
nmap <Leader>- :split<CR>
" Close the split you are in
nmap <Leader>X :action Unsplit<CR>
nmap <Leader>cs :action Unsplit<CR>
" Some search and replace shortcuts
nnoremap <Leader><Leader>r :%s//g<Left><Left>
" Visual Mode
xnoremap <Leader><Leader>r :s//g<Left><Left>
" Open Terminal
nmap <Leader>t :action ActivateTerminalToolWindow<CR>
" Open recent project dialog box
nmap <Leader><Leader>m :action ManageRecentProjects<CR>
" Mapping to mimic BufferExplorer
nmap <Leader>bf :action RecentFiles<CR>
nmap <Leader>bb :action RecentFiles<CR>
" Misc
nmap <Leader>f :action GotoFile<CR>
nmap <Leader><Leader> :action GotoFile<CR>
nmap <Leader>u :action FindUsages<CR>
nmap <Leader>st :action FindInPath<CR>
" Nerdtree - File Explorer
nmap <Leader>e :NERDTreeToggle<CR>
" Toggle ToggleDistractionFreeMode
nmap <Leader>df :action ToggleDistractionFreeMode<CR>
" Create a new file or directory
nnoremap <leader>nf :action NewFile<CR>
nnoremap <leader>nF :action NewDir<CR>
nnoremap <leader>ns :action NewScratchFile<CR>
nnoremap <leader>np :action PhpNewFile<CR>
nnoremap <leader>nc :action PhpNewClass<CR>
" XDebug Shortcuts
nmap <Leader>xl :action PhpListenDebugAction<CR>
nmap <Leader>bp :action ToggleLineBreakpoint<CR>
" Jump to Source
nmap <C>] :action XDebugger.JumpToSource
" View my customized Quicklist
nmap <Leader><leader>l :action QuickList.MyQuickList<CR>
" AceJump Plugin - Jump to Character
nmap <Leader><Leader>w :action AceAction<CR>
" Refactoring
nmap <Leader>rt :action Refactorings.QuickListPopupAction<CR>
" Put search results in the middle of the screen
nnoremap n nzz
nnoremap N Nzz
" Files I open a lot in a project
nmap <Leader>lc :e composer.json<cr>
nmap <Leader>le :e .env<cr>
" Open AI Assist
" map alt+shift+a to :action AIAssistant.ToolsDropdown<CR>
nmap <M-A> :action AIAssistant.ToolsDropdown<CR>
" which-key Settings
" I really don't use WhichKey, so this is not in sync with my
" configuration, but I thought it was worth leaving here
" so you can set it up. If you are learning Vim, this is a great
" plugin to enable as it will pop up a hud if you can't
" remember a key binding.
let g:WhichKeyDesc_windows = "<Space>w Windows"
let g:WhichKeyDesc_windows_delete = "<Space>wd delete"
let g:WhichKeyDesc_windows_split = "<Space>ws split verticle"
let g:WhichKeyDesc_windows_split = "<Space>wh split below"
let g:WhichKeyDesc_windows_split = "<Space>wv split verticle"
let g:WhichKeyDesc_b_stuff = "<Space>b B Stuff"
let g:WhichKeyDesc_recent_files_changed = "<Space>bf Recent Files Changed"
let g:WhichKeyDesc_breakpoint_toggle = "<Space>bp Breakpoint Toggle"
let g:WhichKeyDesc_git_branches = "<Space>br Git Braches"
let g:WhichKeyDesc_split_verticle = "<Space>V split verticle"
let g:WhichKeyDesc_split_horizontal = "<Space>H split horizontal"
let g:WhichKeyDesc_git_pull = "<Space>gp Git Pull"
let g:WhichKeyDesc_file_explorer = "<Space>e File Explorer"
let g:WhichKeyDesc_format_code = "<Space>F Format Code"
let g:WhichKeyDesc_find_file = "<Space>f Get File"
let g:WhichKeyDesc_find_usage = "<Space>u Find Usages"
let g:WhichKeyDesc_terminal = "<Space>t Terminal Window"
let g:WhichKeyDesc_comment = "<Space>\ Comment (single line)"
let g:WhichKeyDesc_highlight_off = "<Space>h Highlight Off"
let g:WhichKeyDesc_safe_paste = "<Space>P Safe Paste (Don't lose buffer)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment