Skip to content

Instantly share code, notes, and snippets.

@wisnuwiry
Last active September 22, 2024 13:51
Show Gist options
  • Save wisnuwiry/4757da890d8ee220e8b6b6a447523eef to your computer and use it in GitHub Desktop.
Save wisnuwiry/4757da890d8ee220e8b6b6a447523eef to your computer and use it in GitHub Desktop.
A basic keyboard shortcut for the vim/nvim editor.

General

  1. Show Documentation: K
  2. Go to Code Action: leader + ca
  3. Go to Definition: gd
  4. Comment: leader + /
  5. Toggle Line Number: leader + n
  6. New Buffer: leader + b
  7. Relative number: leader + rn
  8. Copy whole file: Ctrl + c

Window

  1. Window Up: Ctrl + K
  2. Window Down: Ctrl + J

Gisigns

  1. Preview Hunk: leader + ph
  2. Jump to prev hunk: [c
  3. Jump to next hunk: ]c
  4. Blame file: leader + gb
  5. Reset hunk: leader + rh

Nvimtree

  1. Focus nvimtree: leader + e
  2. Toggle nvimtree: Ctrl + n

Nvterm

  1. New horizontal term: leader + h
  2. New vertical term: leader + v
  3. Toggle horizontal term: Alt + h
  4. Toggle vertical term: Alt + v
  5. Toggle floating term: Alt + i
  6. Escape term: Ctrl + x

LspConfig

  1. Remove workspace folder: leader + wr
  2. LSP definition type: leader + D
  3. LSP Rename: leader + ra
  4. LSP References: gr
  5. Floating diagnostic: leader + f
  6. goto prev: [d
  7. goto next: ]d
  8. diagnostic setloclist: leader + q
  9. LSP Declaration: gD
  10. List workspace folder: leader + wl
  11. LSP formatting: leader + fm
  12. LSP implementation: gi
  13. LSP signature help: leader + ls
  14. Add workspace folder: leader + wa

Telescope

  1. Find in current buffer: leader + fz
  2. Find all: leader + fa
  3. Git commit: leader + cm
  4. Git status: leader + gt
  5. Live grep: leader + fw
  6. Find buffer: leader + fb
  7. Pick hidden term: leader + pt
  8. Help page: leader + fh
  9. Find oldfiles: leader + fo
  10. Find files: leader + ff

About

  1. Mapping Cheatsheet: leader + ch
  2. Nvchad themes: leader + th

References

Arrow

  1. Arrow Left: h

  2. Arrow Right: l

  3. Arrow Top: j

  4. Arrow Bottom: k

  5. Arrow Next by Word: w

  6. Arrow Back by Word: b

  7. Move to end of word: e

  8. Go to fist char current line: 0 (like home in keyboard)

  9. Go to end char current line: $ (like end in keyboard)

Window Navigation

  1. Go to first line current window: H
  2. Go to end line current window: L
  3. Go to middle line current window: M
  4. Move to first line of file: gg
  5. Move to end line of file: G

Editor Navigation

  1. Prev word: b
  2. Next word: w
  3. Prev word & end of word: ge
  4. Next word & end of word: e
  5. Go to line: :{number}

Editing

  1. Copy: yy
  2. Paste: p
  3. Undo: uu
  4. Redo: rr
  5. Delete current line: dd
  6. Select this line: Shift + V
  7. Next line & edit: o
  8. Replace one character: r
  9. Replace mode: R
  10. Uppercase blocked text: gU(visual mode)
  11. Lowercase blocked text: gu(visual mode)

VIM Mode

  1. Normal: esc
  2. Insert: i
  3. Visual: v

File Management

  1. Save curent file: :w
  2. Quit current window: :q
  3. Quit and discard: :q!
  4. Save and quit: :wq

Mark

Creating a mark/bookmark a line of code

  1. Creating: M + [key_of_mark]
  2. Go to mark: ` + [key_of_mark]

Scrolling

  1. Forward scrolling: Ctrl + f
  2. Backward scrolling: Ctrl + b
  3. Forward half scrolling: Ctrl + d
  4. Backward half scrolling: Ctrl + u

Search

  1. Search current file: /[query]
  2. Next query result: n
  3. Prev query result: N

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment