Neovim4J Complete Cheatsheet#

Leader key: <Space> (Space bar)

Quick Help Access#

When you forget a keybinding, use any of these methods:

KeyAction
<Space> (wait 500ms)Show all keybindings automatically
<Space>?Show all keybindings (which-key popup)
<Space><Space>Show all keybindings (which-key popup)
<Space>ckToggle persistent keymaps sidebar (right panel)
<Space>csOpen searchable cheatsheet (Telescope)

Vim Essentials#

Modes#

KeyMode
EscNormal mode (exit any mode)
iInsert mode (before cursor)
aInsert mode (after cursor)
IInsert mode (start of line)
AInsert mode (end of line)
vVisual mode (character selection)
VVisual line mode
<C-v>Visual block mode
:Command mode

Basic Navigation#

KeyAction
hMove left
jMove down
kMove up
lMove right
wJump to next word
bJump to previous word
eJump to end of word
0Jump to start of line
^Jump to first non-blank character
$Jump to end of line
ggJump to top of file
GJump to bottom of file
{Jump to previous paragraph
}Jump to next paragraph
%Jump to matching bracket
<C-d>Scroll down half page
<C-u>Scroll up half page
<C-f>Scroll down full page
<C-b>Scroll up full page

Basic Editing#

KeyAction
iInsert before cursor
aInsert after cursor
oOpen new line below
OOpen new line above
xDelete character (no copy)
ddDelete line
yyYank (copy) line
pPaste after cursor
PPaste before cursor
uUndo
<C-r>Redo
.Repeat last change
~Toggle case
>>Indent line
<<Unindent line
==Auto-indent line

Search & Replace#

KeyAction
/patternSearch forward
?patternSearch backward
nNext match
NPrevious match
*Search word under cursor (forward)
#Search word under cursor (backward)
<Space>nhClear search highlights
:s/old/new/Replace first occurrence in line
:s/old/new/gReplace all in line
:%s/old/new/gReplace all in file
:%s/old/new/gcReplace all with confirmation

File Operations#

CommandAction
:wSave file
:w filenameSave as filename
:qQuit
:q!Quit without saving
:wq or :xSave and quit
:qaQuit all windows
:waSave all files
:e filenameEdit file
:bdClose buffer

File Explorer (nvim-tree)#

Opening File Explorer#

KeyAction
<Space>neToggle file explorer
<Space>nfToggle file explorer on current file
<Space>ncCollapse file explorer
<Space>nrRefresh file explorer

Inside File Explorer#

KeyAction
Enter or oOpen file/folder
aCreate new file/folder
dDelete file/folder
rRename file/folder
xCut file/folder
cCopy file/folder
pPaste file/folder
RRefresh
HToggle hidden files
qClose explorer
?Show help
<C-v>Open in vertical split
<C-x>Open in horizontal split
<C-t>Open in new tab

File Finding (Telescope)#

KeyAction
<Space>ffFind files in current directory
<Space>fpFind files (same as ff)
<Space>frFind recent files
<Space>fsLive grep (search in files)
<Space>fwFind word under cursor
<Space>ctChange colorscheme/theme (with live preview)

Inside Telescope#

KeyAction
<C-j>Move to next result
<C-k>Move to previous result
<C-n>Create new file from prompt
<C-q>Send selected to quickfix list
EnterSelect item
EscClose Telescope

LSP & Code Navigation#

Go To Navigation#

KeyAction
gdGo to definition
gDGo to declaration
giGo to implementation
gtGo to type definition
gr or gRFind references
KShow hover documentation

Code Actions & Refactoring#

KeyAction
<Space>caShow code actions
<Space>rnRename symbol
<Space>rsRestart LSP server

Diagnostics (Errors & Warnings)#

KeyAction
<Space>DShow all diagnostics in buffer
<Space>dShow diagnostic on current line
]dGo to next diagnostic
[dGo to previous diagnostic

Autocompletion (nvim-cmp)#

KeyAction
<C-Space>Trigger completion manually
<C-j>Next completion item
<C-k>Previous completion item
<CR> (Enter)Accept completion
<C-e>Close completion menu

Window Management#

Window Splits#

KeyAction
<Space>svSplit window vertically
<Space>shSplit window horizontally
<Space>seMake splits equal size
<Space>sxClose current split

Window Navigation#

KeyAction
<Space>hMove cursor to left window
<Space>jMove cursor to bottom window
<Space>kMove cursor to top window
<Space>lMove cursor to right window
<C-w>wCycle through windows
<C-w>h/j/k/lMove to left/down/up/right window

Window Resizing#

KeyAction
<C-w>+Increase height
<C-w>-Decrease height
<C-w>>Increase width
<C-w><Decrease width
<C-w>=Make all equal size

Tab Management#

KeyAction
<Space>toOpen new tab
<Space>txClose current tab
<Space>tnGo to next tab
<Space>tpGo to previous tab
<Space>tfOpen current buffer in new tab
gtNext tab (Vim default)
gTPrevious tab (Vim default)
1gtGo to tab 1
2gtGo to tab 2

Buffer Management#

KeyAction
<Tab>Next buffer
<S-Tab>Previous buffer
:bnNext buffer
:bpPrevious buffer
:bdClose/delete buffer
:lsList all buffers
:b<number>Go to buffer number
:b <name>Go to buffer by name (partial match)

Clipboard Operations#

KeyAction
<C-c>Copy to system clipboard (visual mode)
"+yYank to system clipboard
"+pPaste from system clipboard
"*yYank to selection clipboard (Linux)
"*pPaste from selection clipboard (Linux)

Git Integration (Lazygit)#

KeyAction
<Space>ggOpen Lazygit TUI

Inside Lazygit#

KeyAction
SpaceStage/unstage file
aStage all files
cCommit
PPush
pPull
]Next tab
[Previous tab
qQuit
?Show help

Terminal#

KeyAction
<C-7>Toggle floating terminal
<C-\><C-n>Exit terminal mode to normal mode
i or aEnter terminal mode

AI Assistant (CodeCompanion with Ollama)#

KeyActionMode
<Space>acOpen AI chatNormal/Visual
<Space>aeEdit selection with AIVisual
<Space>axExplain codeVisual
<Space>aaShow AI actions menuNormal/Visual
<Space>atToggle AI chat windowNormal

AI Chat Commands#

Inside the AI chat, you can use:

  • /explain - Explain selected code
  • /fix - Fix issues in code
  • /refactor - Refactor code
  • Type naturally to chat with AI

Rust-Specific Commands#

KeyAction
<Space>cRRust code actions
<Space>drRust debuggables (run/debug tests)

Cargo.toml (crates.nvim)#

When editing Cargo.toml:

  • Hover over dependencies for version info and docs
  • Inline diagnostics for outdated versions
  • Code completion for crate names
  • Automatic version suggestions

Common Rust Commands#

CommandAction
:!cargo buildBuild project
:!cargo runRun project
:!cargo testRun tests
:!cargo checkCheck for errors
:!cargo clippyRun clippy linter
:!cargo fmtFormat code

Java Development#

Running Tests#

CommandAction
:!mvn testRun all Maven tests
:!mvn test -Dtest=ClassNameRun specific test class
:!gradle testRun all Gradle tests
:!gradle test --tests ClassNameRun specific test class

Build Commands#

CommandAction
:!mvn compileCompile Maven project
:!mvn packagePackage Maven project
:!gradle buildBuild Gradle project
:!gradle compileJavaCompile Java sources

Plugin Management#

Lazy.nvim (Plugin Manager)#

CommandAction
:LazyOpen Lazy plugin manager
:Lazy updateUpdate all plugins
:Lazy syncSync plugins (install/update/clean)
:Lazy cleanClean unused plugins
:Lazy checkCheck for updates

Mason (LSP/Tool Manager)#

CommandAction
:MasonOpen Mason UI
:MasonUpdateUpdate Mason registry
:MasonInstall <name>Install tool/LSP
:MasonUninstall <name>Uninstall tool/LSP

Debugging (DAP)#

KeyAction
<Space>dbToggle breakpoint
<Space>dcContinue/Start debugging
<Space>dnStep over
<Space>diStep into
<Space>doStep out

Treesitter#

Text Objects (Treesitter)#

KeyAction
vafSelect outer function
vifSelect inner function
vacSelect outer class
vicSelect inner class
va{Select outer block
vi{Select inner block

Health & Diagnostics#

CommandAction
:checkhealthCheck Neovim health
:checkhealth <plugin>Check specific plugin health
:messagesShow message history
:LspInfoShow LSP client info
:LspLogOpen LSP log

Miscellaneous#

CommandAction
:help <topic>Open help for topic
:help keymapsHelp for keymaps
:mapShow all mappings
:nmapShow normal mode mappings
:vmapShow visual mode mappings
:verbose map <key>Show where key was mapped
:source %Reload current file
:!<command>Run shell command
:read !<command>Read command output into buffer

Useful Vim Motions#

Text Objects#

Combine with operators (d, c, y, v):

MotionAction
iwInner word
awA word (with space)
isInner sentence
asA sentence
ipInner paragraph
apA paragraph
i"Inside double quotes
a"Around double quotes
i'Inside single quotes
a'Around single quotes
i( or i)Inside parentheses
a( or a)Around parentheses
i{ or i}Inside braces
a{ or a}Around braces
i[ or i]Inside brackets
a[ or a]Around brackets
itInside tag (HTML/XML)
atAround tag (HTML/XML)

Examples#

CommandAction
diwDelete inner word
ci"Change inside quotes
da(Delete around parentheses
yi{Yank inside braces
vitSelect inside tag

Operators#

KeyAction
dDelete
cChange (delete and enter insert)
yYank (copy)
vVisual select
>Indent
<Unindent
=Auto-indent

Counts & Repeats#

ExampleAction
3ddDelete 3 lines
5jMove down 5 lines
2wMove 2 words forward
4>>Indent 4 lines
3pPaste 3 times

Tips & Workflows#

Creating New Files#

Via File Explorer:

  1. <Space>ne - Open file explorer
  2. Navigate to directory
  3. a - Create new file
  4. Type filename and press Enter

Via Telescope:

  1. <Space>ff - Open file finder
  2. Type new filename
  3. <C-n> - Create file

Fixing Code Errors#

  1. ]d - Jump to next error
  2. <Space>d - View error details
  3. <Space>ca - View code actions
  4. Select and apply fix

Refactoring#

  1. Place cursor on symbol
  2. <Space>rn - Rename
  3. Type new name
  4. Press Enter
  1. gd - Go to definition
  2. K - Read hover documentation
  3. gr - See all references
  4. <C-o> - Jump back to previous location

Search & Replace Workflow#

  1. /pattern - Find pattern
  2. n - Navigate to next match
  3. cgn - Change next match
  4. . - Repeat change on next match
  5. <Space>nh - Clear highlights when done

Multi-Cursor Editing (Substitute)#

  1. :%s/old/new/gc - Replace with confirmation
  2. y - Yes, replace this
  3. n - No, skip this
  4. a - Replace all remaining
  5. q - Quit

Working with Multiple Files#

  1. <Space>ff - Find files
  2. Open first file
  3. <Space>sv - Split vertically
  4. <Space>l - Move to right window
  5. <Space>ff - Find second file

Debugging Workflow#

  1. <Space>db - Set breakpoints
  2. <Space>dr - Start debugger (Rust) or use language-specific command
  3. <Space>dc - Continue execution
  4. <Space>dn - Step over
  5. <Space>di - Step into

Remember#

  • Leader key is <Space> - Press and wait to see all available commands
  • Use <Space>ck for a persistent cheatsheet sidebar
  • Use <Space>cs for searchable cheatsheet via Telescope
  • Use <Space>? or <Space><Space> for which-key popup
  • Most actions can be undone with u
  • :help <topic> is your friend
  • q usually closes popup windows

For more details, see: