Skip to main content

Keybindings & Shortcuts

GentlemanNvim extends LazyVim’s default keybindings with custom mappings optimized for frontend development and AI-assisted workflows.
Leader key is Space. All keybindings shown with <leader> use the spacebar as the prefix.

Quick Reference

AI Assistants

<leader>a prefix for all AI tools

File Navigation

- for Oil, <C-hjkl> for tmux

Obsidian Notes

<leader>o prefix for note-taking

Git Operations

<leader>g for git blame/browse

Essential Keybindings

Saving & Exiting

KeymapModeActionNotes
<C-s>nSave fileCustom save function with notification
<C-c>i, n, vEscape to normalUniversal escape
-- Custom save function
function SaveFile()
  if vim.fn.empty(vim.fn.expand("%:t")) == 1 then
    vim.notify("No file to save", vim.log.levels.WARN)
    return
  end
  
  local filename = vim.fn.expand("%:t")
  local success, err = pcall(function()
    vim.cmd("silent! write")
  end)
  
  if success then
    vim.notify(filename .. " Saved!")
  else
    vim.notify("Error: " .. err, vim.log.levels.ERROR)
  end
end

AI Assistant Keybindings

OpenCode (Active)

KeymapModeAction
<leader>aanToggle OpenCode panel
<leader>asn, xSelect code and submit
<leader>ain, xAsk with empty prompt
<leader>aIn, xAsk with @this: context
<leader>abn, xAsk about current buffer
<leader>apn, xCustom prompt with @this

Built-in AI Prompts

KeymapModeActionPrompt
<leader>apen, xExplain codeExplain selected code
<leader>apfn, xFix codeFix issues
<leader>apdn, xDiagnoseDiagnose problems
<leader>aprn, xReviewCode review
<leader>aptn, xTestsGenerate tests
<leader>apon, xOptimizeOptimize performance
Visual mode selection automatically includes context. Use <leader>ai for custom questions about selected code.

CodeCompanion (When Enabled)

KeymapModeAction
<leader>acn, vToggle chat window
<leader>ann, vNew chat session
<leader>aan, vCodeCompanion actions menu
gavAdd selection to chat
<leader>aevExplain selection
In Chat Window:
  • <CR> (normal) - Send message
  • <C-s> (insert) - Send message
  • <C-c> - Close chat
  • ga (normal) - Accept inline change
  • gr (normal) - Reject inline change

File Navigation

Oil.nvim - File Manager

KeymapModeAction
-nOpen parent directory
<leader>EnOpen Oil in floating window
<leader>-nOpen Oil in current file’s directory
Within Oil Buffer:
keymaps = {
  ["<CR>"] = "actions.select",
  ["<C-s>"] = "vertical split",
  ["<C-v>"] = "horizontal split",
  ["<C-t>"] = "new tab",
  ["<C-p>"] = "actions.preview",
  ["<C-c>"] = "actions.close",
  ["<C-r>"] = "actions.refresh",
  ["-"] = "actions.parent",
  ["_"] = "actions.open_cwd",
  ["g."] = "actions.toggle_hidden",
  ["q"] = "actions.close",
}
Oil edits your filesystem like a buffer. Make changes and save with :w - deletions are permanent!

Goto Preview

KeymapModeAction
gpdnPreview definition
gpDnPreview declaration
gpinPreview implementation
gpynPreview type definition
gprnPreview references
gPnClose all preview windows

Tmux Integration

Seamless Pane Navigation

local nvim_tmux_nav = require("nvim-tmux-navigation")

vim.keymap.set("n", "<C-h>", nvim_tmux_nav.NvimTmuxNavigateLeft)
vim.keymap.set("n", "<C-j>", nvim_tmux_nav.NvimTmuxNavigateDown)
vim.keymap.set("n", "<C-k>", nvim_tmux_nav.NvimTmuxNavigateUp)
vim.keymap.set("n", "<C-l>", nvim_tmux_nav.NvimTmuxNavigateRight)
vim.keymap.set("n", "<C-\\", nvim_tmux_nav.NvimTmuxNavigateLastActive)
vim.keymap.set("n", "<C-Space>", nvim_tmux_nav.NvimTmuxNavigateNext)
KeymapAction
<C-h>Navigate left (Neovim split or tmux pane)
<C-j>Navigate down
<C-k>Navigate up
<C-l>Navigate right
<C-\>Navigate to last active pane
<C-Space>Navigate to next pane
These keybindings work identically in both Neovim and tmux, providing a seamless navigation experience.

Obsidian Note-Taking

Global Obsidian Commands

KeymapModeAction
<leader>ocnCheck/toggle checkbox
<leader>otnInsert template
<leader>oonOpen note in Obsidian app
<leader>obnShow backlinks
<leader>olnShow outgoing links
<leader>onnCreate new note
<leader>osnSearch notes
<leader>oqnQuick switch between notes

Within Obsidian Notes

callbacks = {
  enter_note = function(client, note)
    -- Active when in Obsidian buffer
    vim.keymap.set("n", "gf", function()
      return require("obsidian").util.gf_passthrough()
    end, { buffer = note.bufnr })
    
    vim.keymap.set("n", "<leader>ch", function()
      return require("obsidian").util.toggle_checkbox()
    end, { buffer = note.bufnr })
    
    vim.keymap.set("n", "<cr>", function()
      return require("obsidian").util.smart_action()
    end, { buffer = note.bufnr })
  end,
}
KeymapModeAction
gfnFollow link under cursor
<leader>chnToggle checkbox
<CR>nSmart action (follow link/toggle checkbox)

Search & Grep

Search Selected Text in Current Directory:
vim.keymap.set("v", "<leader>sg", function()
  -- Greps selected text in current working directory
  local selected_text = get_visual_selection()
  require("snacks").picker.grep({ search = selected_text })
end)
Search Selected Text in Git Root:
vim.keymap.set("v", "<leader>sG", function()
  -- Greps selected text from git root
  local git_root = vim.fn.system("git rev-parse --show-toplevel")
  local selected_text = get_visual_selection()
  require("snacks").picker.grep({ search = selected_text, cwd = root })
end)
KeymapModeAction
<leader>sgvGrep selected text (CWD)
<leader>sGvGrep selected text (Git root)

Buffer Management

KeymapModeAction
<leader>bqnDelete all buffers except current
vim.keymap.set(
  "n",
  "<leader>bq",
  '<Esc>:%bdelete|edit #|normal`"<Return>',
  { desc = "Delete other buffers but the current one" }
)

Editing Enhancements

Insert Mode Shortcuts

KeymapModeAction
<C-b>iDelete to end of word (like de)
-- Delete to end of word without leaving insert mode
vim.keymap.set("i", "<C-b>", "<C-o>de")

Disabled Default Keybindings

The following LazyVim defaults are disabled to prevent conflicts:
These keybindings are explicitly disabled:
  • <A-j> / <A-k> - Move lines up/down (insert, normal, visual)
  • J / K - Move visual selection (visual mode)
-- Disable line movement keybindings
vim.api.nvim_set_keymap("i", "<A-j>", "<Nop>", { noremap = true })
vim.api.nvim_set_keymap("i", "<A-k>", "<Nop>", { noremap = true })
vim.api.nvim_set_keymap("n", "<A-j>", "<Nop>", { noremap = true })
vim.api.nvim_set_keymap("n", "<A-k>", "<Nop>", { noremap = true })
vim.api.nvim_set_keymap("x", "J", "<Nop>", { noremap = true })
vim.api.nvim_set_keymap("x", "K", "<Nop>", { noremap = true })

Git Integration

KeymapModeAction
<leader>gbnOpen Git blame window
<leader>gonBrowse file in GitHub/GitLab

Utility Keybindings

Marks

KeymapModeAction
<leader>mdnDelete all marks
vim.keymap.set("n", "<leader>md", function()
  vim.cmd("delmarks!")
  vim.cmd("delmarks A-Z0-9")
  vim.notify("All marks deleted")
end)

Screen Recording

KeymapModeAction
<leader>uknToggle Screenkey (show keypresses)

Zen Mode

KeymapModeAction
<leader>znToggle Zen Mode (distraction-free)

LazyVim Default Keybindings

GentlemanNvim inherits all LazyVim default keybindings. Key highlights:
File Navigation:
  • <leader>ff - Find files
  • <leader>fg - Live grep
  • <leader>fb - Browse buffers
  • <leader>fr - Recent files
LSP:
  • gd - Go to definition
  • gr - Go to references
  • K - Hover documentation
  • <leader>ca - Code actions
  • <leader>rn - Rename symbol
Diagnostics:
  • ]d - Next diagnostic
  • [d - Previous diagnostic
  • <leader>cd - Line diagnostics
Windows:
  • <C-w>s - Split horizontal
  • <C-w>v - Split vertical
  • <C-w>q - Close window
Full documentation: LazyVim Keymaps

Which-Key Integration

Press <leader>? to show context-aware keybindings:
vim.keymap.set("<leader>?", function()
  require("which-key").show({ global = false })
end)
Start typing a keymap sequence and pause - which-key will show available completions after 300ms.

Custom Functions

Some keybindings trigger custom Lua functions:

SaveFile()

Enhanced save with notifications:
function SaveFile()
  -- Check if buffer has a file
  if vim.fn.empty(vim.fn.expand("%:t")) == 1 then
    vim.notify("No file to save", vim.log.levels.WARN)
    return
  end

  local filename = vim.fn.expand("%:t")
  local success, err = pcall(function()
    vim.cmd("silent! write")
  end)

  if success then
    vim.notify(filename .. " Saved!")
  else
    vim.notify("Error: " .. err, vim.log.levels.ERROR)
  end
end

Visual Selection Grep

Intelligent text search with automatic escaping:
vim.keymap.set("v", "<leader>sg", function()
  local start_pos = vim.fn.getpos("'<")
  local end_pos = vim.fn.getpos("'>")
  local lines = vim.fn.getline(start_pos[2], end_pos[2])
  
  if #lines == 0 then return end
  
  -- Handle single/multi-line selection
  if #lines == 1 then
    lines[1] = string.sub(lines[1], start_pos[3], end_pos[3])
  else
    lines[1] = string.sub(lines[1], start_pos[3])
    lines[#lines] = string.sub(lines[#lines], 1, end_pos[3])
  end
  
  local selected_text = table.concat(lines, "\n")
  selected_text = vim.fn.escape(selected_text, "\\.\*[]^$()+?{}")
  
  require("snacks").picker.grep({ search = selected_text })
end)

Cheat Sheet

AI Assistant

  • <leader>aa - Toggle AI
  • <leader>ai - Ask AI
  • <leader>ape - Explain
  • <leader>apf - Fix

Files

  • - - Oil (parent)
  • <leader>E - Oil (float)
  • <leader>ff - Find file
  • <leader>fg - Grep

Navigation

  • <C-hjkl> - Tmux/splits
  • gd - Definition
  • gpd - Preview def
  • gP - Close previews

Notes

  • <leader>on - New note
  • <leader>os - Search
  • <leader>oq - Quick switch
  • gf - Follow link

Build docs developers (and LLMs) love