Neovim Keymap Cheatsheet: Josean Martinez’s Configuration

kazma 成大資安社 創辦人/社長

Neovim Keymap Cheatsheet

這篇文章主要是要整理給自己看的筆記 XD
目前使用的是一個 YouTuber, Josean Martinez 的配置:附上連結:

Preview

附上這個配置的一些美美預覽圖:

  • Cover:
    cover

  • Telescope:
    file-explorer

  • Lazy.nvim:
    lazy

  • File Explorer:
    tree

  • Lsp:
    lsp

  • Lazy git
    lazy-git

Keymaps

Basic

  • <leader> is eual to <Space> here
  • jk to exit Insert to Normal
  • <leader>nh to clear search highlights
  • <leader>+ to increase number
  • <leader>- to decrease number
  • <Ctrl>o to jump backward
  • <Ctrl>i to jump forward

Split

  • <leader>sv to split window vertically
  • <leader>sh to split window horizontally
  • <leader>se to make splits equal size
  • <leader>sx to close current split
  • <leader>sm to maximize/minimize a split

Tab

  • <leader>to to open new tab
  • <leader>tx to close current tab
  • <leader>tn to go to next tab
  • <leader>tp to go to previous tab
  • <leader>tf to open current window in new tab

Lazy.nvim plugin manager

  • :Lazy to open plugin manager

Tmux navigator

  • <Ctrl>h/j/k/l to move between tmux & split window

File explorer

  • <leader>ee to toggle file explorer
  • <leader>ef to toggle file explorer on current file
  • <leader>ec to collapse file explorer
  • <leader>er to refresh file explorer

Which key

  • print hint message after typing a letter

Telescope

  • <leader>ff to fuzzy find files in cwd
  • <leader>fr to fuzzey find recent files
  • <leader>fs to find string in cwd
  • <leader>fc to find string under cursor in cwd
  • <leader>ft to find todos
  • <Ctrl>j/k to move in the result
  • <Ctrl>q to quit the telescope

Auto session

  • <leader>wr to restore session for cwd
  • <leader>ws to save session for cwd

File management

  • r to rename a file
  • a to add a file

Treesitter

  • :Inspect Tree to open syntax tree
  • <Ctrl><Spc> to select node and use it again to select parent node

Autocomplete

  • <Ctrl>k to select previous suggestion
  • <Ctrl>j to select previous suggestion
  • <Ctrl>b to scroll up in docs
  • <Ctrl>f to scroll down in docs
  • <Ctrl><Spc> to show completion suggestion
  • <Ctrl>e to close completion window
  • <Enter> to confirm current selection

Comments

  • gcc to comment/uncomment current line
  • gc<position> to comment/uncomment
  • TODO: in comment to create TODO tag
  • BUG in comment to create BUG tag
  • HACK in comment to create HACK tag

Substitute

  • s to substitute with motion
  • ss to substitute line
  • S to substitute end of line

Surround

  • ys<motion> to add surrounding
  • ds<motion> to delete surrounding
  • cs<motion> to change surrounding

Lsp

  • :Mason to open mason
  • gR to show definition, references
  • gD to go to declaration
  • gd to show lsp definition
  • gi to show lsp implementations
  • gt to show lsp type definition
  • <leader>ca to see available code action
  • <leader>rn to smart rename
  • <leader>D to show diagnostics
  • <leader>d to show diagnostics for line
  • [d to jump to previous diagnostics in buffer
  • K to show documentation for what is under cursor
  • <leader>rs to mapping to restart lsp if necessary

Trouble

  • <leader>xx to open/close trouble list
  • <leader>xw to open trouble workspace diagnostics
  • <leader>xd to open trouble document diagnostics
  • <leader>xq to open trouble quick fix list
  • <leader>xl to open trouble location list
  • <leader>xt to open todos in trouble

Linting

  • <leader>l to trigger linting for current line

Git Integration

  • ]h to go to next hunk
  • [h to go to previous hunk
  • <leader>hs to stage hunk
  • <leader>hr to reset hunk
  • <leader>hS to stage buffer
  • <leader>hR to reset buffer
  • <leader>hu to undo stage hunk
  • <leader>hp to preview hunk
  • <leader>hb to blame line
  • <leader>hB to toggle line blame
  • <leader>hd to diff this
  • <leader>hD to diff this ~

Lazygit

  • <leader>lg to open lazy git
  • Title: Neovim Keymap Cheatsheet: Josean Martinez’s Configuration
  • Author: kazma
  • Created at : 2024-05-01 15:59:06
  • Updated at : 2024-05-02 17:36:16
  • Link: https://kazma.tw/2024/05/01/Neovim-Keymap-Cheatsheet-Josean-Martinez’s-Configuration/
  • License: This work is licensed under CC BY-NC-SA 4.0.
 Comments