Skip to content

Instantly share code, notes, and snippets.

@Archisman-Mridha
Last active May 2, 2024 00:49
Show Gist options
  • Save Archisman-Mridha/41923c35fec46d46497a06bdca56cb6f to your computer and use it in GitHub Desktop.
Save Archisman-Mridha/41923c35fec46d46497a06bdca56cb6f to your computer and use it in GitHub Desktop.
Neovim cheatsheet

Anatomy of a motion - Command + Count + Motion

Navigation

  • Jump to beginning of line - 0 / _ (jumps to the first non-whitespace character)
  • Jump to end of line - $
  • Move forward by 1 word - w (jumps to beginning of the next word) / e (jumps to end of the next word)
  • Move backward by 1 word - b (jumps to beginning of the previous word) / ge (jumps to end of the previous word)
  • Jump to beginning of the file - gg
  • Jump to end of the file - G
  • Move forward to the next instance of the character (( in this case) - f( // NOTE : Repeat motion using , (for backwards movement) or ; (for forward movement)
  • Move forward upto (right before but not on) the next instance of the character (( in this case) - t( // NOTE : Repeat using , (for backwards movement) or ; (for forward movement)
  • Jump by half the window height - ctrl + d (to jump down) / ctrl + u (to jump up)
  • Bring current line to the view centre - zz
  • Move by a paragraph - { (move up) / } (move down)
  • Go to definition - gd
  • Go back to previous place - ctrl + o | Go back to next place - ctrl + i
  • Show info about symbol - K
  • Go to the end of the line and enter insert mode - I
  • Go to the end of the line and enter insert mode - A
  • Enter normal mode from insert mode (temporarily) - ctrl + o
  • Reveal current file in NeoTree - space + fr

NOTE : Use W to select all of the contiguous text.

Editing

  • Undo - u
  • Redo - ctrl + r
  • Create new line and enter insert mode - o (create new line after the current line) / O (create new line before the current line)
  • Enter insert mode - i (in the left side of the character you're currently on) / a (in the right side of the character you're currently on)
  • Toggle comment for a line / selection - gcc
  • Change inside word - ciw | Change around word - caw
  • Delete line - dd
  • Delete all contents in the file - dG
  • Delete from current to the first occurrence of the character (_ in this case) - df_ / dt_ (excludes '_')
  • Delete word - dw (in normal mode) / ctrl + w (in insert mode)
  • Delete letter - dl
  • Delete around - da | Delete inside - di
  • Increment number - ctrl + a | Decrement number - ctrl + x
  • Write to file using sudo - w !sudo tee %
  • Make everything in selection undercase - u
  • Squeeze up next line appending its contents to the current line - shift + down-arrow
  • Increment a number - ctrl + a

Formatting and indentation

  • Indent a paragraph - =ap

Copying and pasting

  • Enter visual mode (for selecting) - v
  • Enter line visual mode (for selecting) - shift + v
  • Select till matching character (like from opening till closing paranthesis) - v%
  • Copy selected text (yank) - y // NOTE : Yanked and deleted content go to the same buffer
  • Copy line - yy / shift + v + y
  • Paste - v (in normal mode) / ctrl + r* (in insert mode)
  • Yank everything inside paranethesis - yi(
  • Yank everything till the closing paranthesis - yt(

Searching

If you want to search, type / and then type the search query. Use n to go the next result / shift + n to go to the previous result. Press * to automatically search using the word you're on as the query.

File management

  • Create file / folder - a
  • Delete file / folder - d
  • Find files / folders - ff
  • Open telescope - space + space
  • Refresh file-tree - R

Buffer management

  • Toggle buffers - space + bb
  • Delete buffer - space + bd

Others

  • Change theme - space + uC
  • Repeat last operation - .
  • Toggle windows - ctrl + w
  • New terminal - ctrl + /
  • Vertical split - space + | | Horizontal split - space + -
  • Fold visual selection - zf | Toggle fold - za
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment