-
fuzzyness all around!
-
Many useful functions and mappings.
-
Some unique functions for math.
This document provides comprehensive documentation for the custom Vim configuration defined in mappings.vim and hacks.vim.
- Core Functions
- Navigation & Movement
- Insert Mode Mappings
- Leader Key Mappings
- Function Keys
- Search & Find
- Git Integration
- Window & Buffer Management
- Text Manipulation
- Python & REPL Integration
- Fuzzy Finding (FZF/Leaderf)
- Utility Functions
- Math Support
- Operator Motions
- Ctrl-A Prefix - Fuzzy Finding & Navigation
- Tracks the last visited window across buffers
- Ignores terminal buffers and empty buffers
- Stores window history in
g:lastWindows
- Opens the last visited window in a vertical split
- Command:
:LastWindow
- Loads cached directory list from
dirs.cache - Uses Python pickle for serialization
- Tracks visited directories automatically
- Prevents duplicate entries
- Saves to
dirs.cache
- Powerful text transformation function
- Syntax:
:GL /pattern/mode command - Modes:
rpy- Run Python and replacepy- Run Python and append
- Example:
:GL /\d\+/rpy match*2(doubles numbers)
- Searches current buffer for pattern
- Populates quickfix list with matches
- Variants:
M pattern- Case-sensitive matchMC pattern- Case-insensitive matchMW pattern- Word boundary match
- Commands:
:M <pattern>- Match pattern:MC <pattern>- Case-insensitive match:MW <pattern>- Word match:VG <pattern> [files]- Vimgrep across files
- Deletes current file and buffer with confirmation
- Command:
:DeleteMe
- Moves/renames current file
- Command:
:MoveMe [path] - Interactive if no argument provided
<c-]>- Search forward (Lightspeed_s)<c-[>- Search backward (Lightspeed_S)<M-f>- Two-character search<M-t>- Till character (QuickScope enhanced)?- Single line search
<c-h>- End of word bidirectional<M-h>- End of word left<M-d>- Beginning of word leftmL- Line bidirectional jump
<c-/>- Enhanced f (forward to char)<M-/>- Enhanced T (backward till char)<c-'>- Enhanced t (forward till char)<m-'>- Enhanced F (backward to char)f/F- QuickScope-enhanced find
&- Jump to next quote/string<c-7>- Jump to previous quote/string<c-5>- Next block (z%)
Quick Navigation:
_u- Last window_U- Telescope last windows (if configured)_.- Change directory up (..)_-- Change to previous directory_t- Last tab_b/_B- Next/Previous buffer_P/_N- Previous/Next window
Diff Operations:
_g- Diff get_p- Diff put- Visual mode:
_g/_pwork on selection
Other:
_f- LSP format_wo- Workspaces open_#- Alternative buffer
<M-Left>- Word backward (B)<M-Right>- Word forward (W)<M-Up>- Backspace<M-Down>- Word jump
<m-h>/<m-j>/<m-k>/<m-l>- Vim direction keys
- Activates timed insert mode
- Auto-exits after inactivity
- Trigger:
<Insert>key in normal mode,<F12>,<F13>
s- Insert character before cursorS- Insert character after cursor(- Insert character before (alternative))- Insert character after (alternative)
<c-k>- Recall inserts or navigate completion<c-b>- Get all inserts<c-f>- Keyword completion<c-z>- Smart completion (context-aware)<c-.>- Fuzzy completion info<m-f>- Path completion<m-c-k>- Dictionary completion
<c-j>- Accept Copilot suggestion<M-j>- Next Copilot suggestion
<c-l>- Undo<c-w>- Delete word backward<c-a>- Increment number<c-;>- Repeat last motion<M-Space>/<S-CR>- Normal mode command<c-i>- Paste formatted
<leader>of- Open file (split)<leader>og- Open file with fuzzy find<leader>OF- Open MRU in split<leader>ov- Open newplug.vim<leader>om- Open mappings.vim<leader>OM- Open mappings.vim in split<leader>on- Open myinit.lua<leader>ON- Open myinit.lua in split
<leader>oc- Open quickfix<leader>ol- Open location list<leader>W- Set wrap
<leader>em- Show messages (Noice or manual)<leader>EM- Noice telescope<leader>XF- LSP diagnostics (location list, filtered)<leader>xf- LSP diagnostics (quickfix, git only, filtered)
<leader>as- Toggle buffer auto-save<leader>AS- Toggle global auto-save<leader>SI- Toggle save inserts<leader>rn- Toggle relative numbers
<leader>do- Diff off<leader>du- Diff update<leader>dt- Diff this<leader>g2- Diffget from buffer 2<leader>g3- Diffget from buffer 3
<leader>1-<leader>9- Jump to tab 1-9
<F1>- Help for word under cursor
<F2>- Execute current line as Vim command<S-F2>- Execute as Lua<F2>(Visual) - Execute selection as Vim command<S-F2>(Visual) - Execute selection as Lua<F6>(Visual) - Print Lua expression
<F3>- Send line to REPL<F3>(Visual) - Send selection to REPL<F4>- Clear and run current file in REPL<F8>- Clear REPL
<F5>- IPython run<S-F5>- Run file with<leader>rf
<S-F6>- Delete line and paste 2 lines up<S-F7>- Yank and paste below<S-F8>- Delete and paste below
<F12>/<F13>- Start special insert mode<F12>(Insert) - Single normal command<F13>(Insert) - Escape
Function: ToggleSearch()
mS- Toggle incremental search & highlight
m/- Search forward (no ignorecase, no incsearch)m?- Search backward (with incsearch & hlsearch)
,- Leaderf line search (popup)m,- Leaderf line with preview<m-,>- Telescope LSP symbols
TT- Search word under cursorT(Visual) - Search visual selectionMm/MM- Search inner word/WORDY(Visual) - Match selection in current fileM(Visual) - Same as YRR(Visual) - Search selection with/
L(Operator)** - Interactive ripgrep with motionL(Visual) - Ripgrep visual selectionLl/LL- Ripgrep inner word/WORD
<leader>gm- Go to mapping definitionmge(Visual) - Exact ripgrep searchMG- Lookup word in current file
<c-_>- Search with history<c-s>- Smart search (EasyMotion)<m-s>- Till search
mg- Git status (with custom git dir)mG- Standard Git status<leader>Gc- Git commit<leader>GC- Git commit --amend --no-verify<leader>Ga- Git add current file<leader>Gt- Git commit current file
<leader>Gd- Git diff split<leader>GD- Git diff 3-way merge<leader>GDh- Git diff vs HEAD^<leader>Gs- Git diff --staged
<leader>Gl- Git log (all)<leader>GL- Git log (current file)
<leader>Ge- Git edit<leader>Gr- Git read<leader>Gg- Git grep<leader>Gb- Git branch<leader>Go- Git checkout
<leader>Gp- Git push<leader>GP- Git push --force<leader>Gu- Git push upstream<leader>GU- Git push -f upstream
<leader>Gmo- Merge with ours strategy<leader>Gmt- Merge with theirs strategy
[h- Previous hunk]h- Next hunk
- Git commands in current working directory
- Usage:
:GCWD [git-command]
|(bar) - Leaderf buffer list (all)m|- Leaderf buffer list (current tab)<M-Bslash>- Buffer list (no jump to existing)
_b/_B- Next/Previous buffer_#- Alternative buffer
Function: VspIfNeed()
- Creates vertical split if none exists
- Otherwise jumps to existing right window
_P/_N- Previous/Next windowmo- Close splits & open buffer listmO- Close splits & open all buffers OR swap windows
Function: CloseAllWindowsButCurrent()
- Closes all windows except current
- Handles NvimTree specially
Function: CloseVspIfNeed()
- Intelligently closes rightmost split
- Recursive cleanup
<leader>1-9- Jump to tab 1-9_t- Last tab
Command: TN [file]
- Opens file in existing tab if open
- Otherwise creates new tab
mt- Toggle NvimTree (defined in Lua)MT- Open NvimTree at current file location- Function:
CloseAllNR()- Close all netranger windows
m'- Surround word with single quotesm{- Surround word with bracesm[- Surround word with bracketsm(- Surround word with parentheses
Function: PasteFormat(x)
]p/]P- Smart paste (formats based on content)- Handles newlines intelligently
Function: MPf() & Domp()
mp- Paste on new line with formattingmP/MP- Paste without newlinesmP(Visual) - Paste over selection
mn- Create new empty line below
mY- Yank line without newlinemC- Copy file path to clipboard
msA- Remove all leading/trailing spaces & empty lines (file)msa- Remove all leading/trailing spaces & empty lines (line)msb- Remove trailing spaces & empty lines (file)mss- Remove multiple spaces (line)msl- Remove trailing spaces (file)msc- Remove trailing spaces preserving text (file)
Function: AlignWithTopLine()
- Aligns selection with line above
- Python-aware indentation
Function: ConditionalAlign()
- Python: Uses autopep8
- Others: Standard Vim format
Function: FormatCurrentBlock()
- Formats current Python block
<plug>fff- Format block (can be mapped to ==)
Function: ReplaceCasing(word, oldword)
- Smart case-insensitive replace
Function: CreateList()
- Command:
:CL(visual mode) - Converts lines to quoted list items
mwin- Convert Windows line endings
<M-r>- Run Python command (input)<M-k>- Word object info<M-g>(Insert) - IPython complete
<leader>rf- Run current file (Python: %run, PS1: custom)<leader>rb- Interrupt IPython<leader>rt- Terminate IPython<leader>rc- Run cell
<leader>ot- Terminal in new tab<leader>tt- Terminal in vertical split (CWD)<leader>Tt- Terminal in vertical split (file dir)<leader>gt- WSL terminal in vertical split
<leader>mb- Insert ipdb breakpoint
<leader>vl- Launch debugger<leader>vr- Reset debugger<leader>vs- Stop debugger<leader>vR- Restart debugger<leader>vp- Pause debugger
Function: MakeJson([override])
- Creates .vimspector.json for Python debugging
<c-a>f- Files in CWD (FzfLua)<c-a>F- Files in current file's directory (Telescope/Leaderf)<c-a>d- Change directory (from cache, with mark)<c-a>D- Change directory (from cache, no mark)
<c-a>g- Interactive ripgrep<c-a>G- Live grep<c-a>l- All inserts (current buffers)<c-a>L- Lines in all buffers<c-a>a- Ag search
<c-a>b- Windows<c-a>w- Tabs<c-a>j- Jumplist (Telescope)<c-a>h- File history<c-a>H- Bash history
<c-a>r- Leaderf recall<c-u>- Same as<c-a>r<c-a>R- Leaderf Rg recall<c-a>c- Command history<c-a>C- Commands<c-a>m- Mappings (keys only)<c-a>M- Mappings (with descriptions)<c-a>s- Snippets
mm- Leaderf MRU (fuzzy)mM- MRU (ordered)M,- CtrlPm.- CtrlP (clear cache)
<c-a>(Command) - Complete from command history<c-b>(Command) - Edit in command window
<c-p>- Change dir & open file<m-p>- Open in vertical split<m-o>- Open with FZF<m-'>- Open in git root<c-b>- Close splits & open buffer
mH- Leaderf helpMh/MH- Standard help<m-k>(Normal)** - Leaderf help for word<m-k>(Visual) - Leaderf help for selection
.- Last changemI- Last insert positionmM- Last modificationmH- Search mark ()- Mark tracking functions in hacks.vim:266-269
<leader>.- Jump to last change<leader>'- Jump to last positionmb/mB/mv- Jump list navigation
Function: MapR()
R{char}- Show register content<M-0>to<M-9>- Show numbered registers<M-->/<M-=>- Show + and = registers
- Auto-save workspace
- Clipboard synchronization
- Runs periodically in background
- Executes command and returns output as string
- Executes command and opens result in new tab
- Returns current visual selection as string
- Copies current file path to clipboard
- Mapped to:
mC
- Command:
:Tailf - Continuously reloads and shows end of file
- Switch between PowerShell and default shell
P <cmd>- Run PowerShell commandTP- Toggle PowerShell mode
Functions: Goprev() & Gonext()
<S-F3>- Previous item<S-F4>- Next item- Auto-detects quickfix vs location list
Function: DiagnosticsGitOnly()
- Filters diagnostics to git-tracked files only
<leader>xf- Execute with filter
mu- Toggle UndoTree
mws- Save CtrlSpace workspacemwd- Save default workspace
__- Comment out (vim-commentary)_+- Uncomment
<c-t>(Visual) - Translate selection
mf- Open file directorymF- Execute function under cursor
md- Diff update
<leader>rd- Force redraw (Ctrl-L)
gp- Edit file under cursor in pycharm (translated path for Windows)mc- Change directory to current file
mj- Clear search highlight<c-CR>- Clear highlight & dismiss Noice<Home>- Go to first non-blank characterx- Delete without copying (black hole register)
Defined in: inserts.vim (sourced from hacks.vim:4)
Functions:
AddInsert(text)- Add text to insert cacheRecallInserts(mode)- Recall from insert cacheGetAllInserts()- Get all inserts (FZF)EnableTrackInserts(enable)- Toggle tracking
Related:
SaveInsertsFunc(a)(hacks.vim:84) - Persists inserts- Insert cache stored per-file in
b:inserts
- Smart completion behavior
- Handles keyword vs other completion
<c-z>(Insert) - Invoke smart complete
- FZF-based completion with preview
<c-.>(Insert/Command) - Fuzzy complete anything
- Operator-pending motions for search
L{motion}- Ripgrep with motionM{motion}- LeaderfLine with motion
- Auto-indentation with autopep8
- IPython integration
- Debugging support
- Custom terminal setup
- RunPS integration
g:vimloc- Vim configuration directoryg:dirs- Cached directories listg:lastWindows- Window historyg:lastWinName- Last window nameg:lastdir- Last directory
g:init- Initialization flagg:pwmod- PowerShell mode flagg:on_ek_computer- Machine-specific flagg:special_insert- Special insert mode flagg:detect_mod_reg_state- Register change detection
g:autosaveWS- Auto-save workspace timerg:timerb- Clipboard sync timerg:inactivity_limit- Special insert timeoutg:check_frequency- Check interval
g:sh,g:shf,g:shr,g:shq,g:shxq,g:shellpipe- Shell settings backup
b:save_inserts- Enable insert tracking per bufferb:auto_save- Enable auto-save per bufferb:inserts- Insert cache per bufferb:git_dir- Git directory override
BufWinLeave- SaveLastWindow()DirChanged- SaveLastDir()TextYankPost- SaveLastReg()CursorMoved- DetectRegChangeAndUpdateMark()
InsertEnter- CheckSpecialInsert()InsertLeave- EndSpecialInsert(), auto-markTabLeave- Save last tab number
FileType *- Set up Lightspeed mappings with IsRegular() check
ExitPre- StopTimerFunc()
:GL /pattern/mode command- Global line processing with Python:M <pattern>- Match pattern in current buffer:MC <pattern>- Case-insensitive match:MW <pattern>- Word match:VG <pattern> [files]- Vimgrep across files:MESC <pattern>- Match with full regex:CL- Create list from visual selection
:TN [file]- Tab new (reuse existing):LastWindow- Open last window:DeleteMe- Delete current file:MoveMe [path]- Move/rename current file
:Tailf- Tail -f current file:P <cmd>- Run PowerShell command:TP- Toggle PowerShell mode:Filter <cmd> [delete]- Filter file through command:GCWD [git-cmd]- Git command in CWD
- All standard Fugitive commands
- Custom
:GCWDvariant
:PyRun- Run Python with IPython completion
- Search current word in all files:
LlorLL - Open recent file:
mm - Switch between last two tabs:
_t - Copy file path:
mC - Clean up whitespace:
msA(all) ormsa(current line) - Smart paste:
]por]P - Navigate quickfix:
<S-F3>/<S-F4> - Open terminal:
<leader>tt - Format Python block: Use
<plug>fff - Recall insert history:
<c-k>in insert mode
- Open file with
<c-p> - Set up IPython terminal with
<leader>tt - Send code to REPL with
<F3> - Run entire file with
<leader>rf - Debug with
<leader>mb(set breakpoint) and<leader>vl(launch)
- Check status with
mg - Stage file with
<leader>Ga - Commit with
<leader>Gc - Push with
<leader>Gp - View diff with
<leader>Gd
- Search in current file: visual select +
Y - Search in project: visual select +
L - Filter results: use quickfix commands
- Replace: use
:cdoor standard substitute
- Many functions require specific plugins (Leaderf, FZF, Telescope, etc.)
- Some mappings use
<Plug>which requires the corresponding plugin - The configuration heavily uses Python (Python 2 and 3) for certain features
- Timer functions run in background for auto-save and clipboard sync
- Special insert mode provides timed insert with auto-exit
- The system tracks inserts, windows, and directories for quick access
- Git integration requires vim-fugitive
- EasyMotion and Lightspeed are used extensively for navigation
- .vimrc: Main Vim configuration entry point
- vimsettings.vim: General Vim settings and options
- hacks.vim: Core functions, utilities, tracking systems
- mappings.vim: All key mappings, leader mappings, function keys
- inserts.vim: Insert tracking system (sourced by hacks.vim)
- math.vim: LaTeX and math support functions
- newplug.vim: Plugin manager configuration
- pluginSettings.vim: Plugin-specific settings
- myinit.lua: Main Lua initialization
- t.lua: Utility Lua functions
- myplugins/: Lua plugin configurations
- avante.lua: Avante plugin config
- cmp.lua: Completion plugin config
- lazyplugs.lua: Lazy plugin loader config
- lspconfig.lua: LSP configuration
- noice.lua: Noice UI plugin config
- repmo.lua: Repeat motion plugin config
- after/ftplugin/: File type specific configurations
- Python, JavaScript, HTML, Markdown, Go, Java, etc.
- Indentation settings (2spaces.vim, 4spaces.vim, tabs.vim)
- autoload/plug.vim: Vim-plug plugin manager
- UltiSnips/tex.snippets: LaTeX snippets
- installnvim.ps1 / installnvim.sh: Neovim installation scripts
- installscript.sh: General installation script
- pycharmst.py: PyCharm integration script
- recurse.ps1: PowerShell recursion utilities
- README.md: This file - comprehensive configuration documentation
- vimlec/: Vim lecture notes and tutorials
- vimlec.md: Main lecture notes
- beginner.md: Beginner tutorial
- .gitignore: Git ignore patterns
- .gitmodules: Git submodules configuration
- .eslintrc.yml: ESLint configuration
- vim-indentwise: Indentation-based navigation plugin (submodule)
- vim-tex support
- Math snippets taken from https://castel.dev/post/lecture-notes-1/
~{letter}- Insert greek letters- Example:
~afor alpha
- Example:
@{char}- Insert math operators- Example:
@cfor\mathcal{}
- Example:
<cmd>+<d>- Math functions (same as LyX bindings)<cmd>+<b>- Letter formatting- Works in both insert and normal mode
- Note: Requires Vim GUI that supports
<d->for cmd key
- Operates on the beginning/head portion of text
- Use with motions to select from start to motion point
L{motion}- Interactive ripgrep with motion- Searches for text selected by motion across files
- Usage Examples:
Liw- Ripgrep inner wordLi'- Ripgrep text inside quotesLip- Ripgrep paragraph
- Related mappings:
Ll- Ripgrep inner wordLL- Ripgrep inner WORDL(Visual) - Ripgrep visual selection
- Enhanced till motion with operator support
- Works with text objects for precise selection
The <c-a> prefix provides quick access to fuzzy finding and navigation features. All mappings use FZF, Telescope, or Leaderf for fuzzy search.
<c-a>f- Files in CWD (FzfLua)<c-a>F- Files in current file's directory (Telescope/Leaderf)<c-a>d- Change directory (from cache, with mark)<c-a>D- Change directory (from cache, no mark)<c-a>h- File history (MRU)
<c-a>g- Interactive ripgrep (text in files)<c-a>G- Live grep<c-a>l- All inserts (lines in current buffer)<c-a>L- Lines in all open buffers<c-a>a- Ag search
<c-a>b- Windows (also available as|)<c-a>w- Tabs<c-a>j- Jumplist (Telescope)
<c-a>c- Command history (:commands)<c-a>C- All defined commands<c-a>H- Bash history<c-a>r- Leaderf recall (also<c-u>)<c-a>R- Leaderf Rg recall
<c-a>m- All custom key mappings (search by shortcut key)<c-a>M- All mappings (full text search with descriptions)
<c-a>s- Snippets (UltiSnips)
<M-Bslash>- Window titles (navigate between windows)