Personal Neovim Cheatsheet Cheat Sheet

A Software › Text Editor cheat sheet in English by dcschmid

This are my personal cheatsheet for Neovim

34,623 views 4,439 downloads 10 Jul 2022 History

Basic

-
open netrw file explorer
leader + w
fast saving
leader + ba
close all the buffers

Tab Management

leader + nt
open new tab
leader + tc
close actual tab
leader + tl
toggle between this and the last accessed tab
leader + tn
switch to next tab
leader + to
close other tabs
leader + tp
switch to previous tab

Telescope

;
Lists open buffers in current neovim instance
control + g
Fuzzy search through the output of git ls-files command
control + p
Lists files in your current working directory
leader + fg
Search for a string in your current working directory and get results live as you type
leader + g
Searches for the string under your cursor in your current working directory

Packer Commands

:Packe­rClean
Remove any disabled or unused plugins
:Packe­rCo­mpile
Regenerate compiled loader file
:Packe­rIn­stall
Clean, then install missing plugins
:Packe­rSync
Perform Packer­Update and then Packer­Compile
:Packe­rUpdate
Clean, then update and install plugins

LSP Typescript Utils

leader + gi
Rename TypeScript file and update imports
leader + go
Import all missing imports in TS Files
leader + gs
Organize imports in TypeScript Files

Trouble

leader + xd
switch to document diagno­stics from the builtin LSP client
leader + xr
refresh the active list
leader + xw
switch to workspace diagno­stics from the builtin LSP client
leader + xx
toggle Trouble window

Git

:Git
run git command in terminal, Eg: :Git checkout -b test
leader + gR
Revert the current file to the specific commit
leader + gb
Open blame window
leader + gd
Opens a new diff that compares against the current index
leader + gn
Create a pull request with the target branch is set in the target­_branch option
leader + go
Open file/f­older in git repository
leader + gp
Open pull request of the current branch
leader + gr
Revert to the specific commit

Git conflict

:GitCo­nfl­ict­ListQf
Show all conflicted files in quickfix window
c0 or :GitCo­nfl­ict­Cho­oseNone
Select both none of the changes
cb or :GitCo­nfl­ict­Cho­oseBoth
Select both changes
co or :GitCo­nfl­ict­Cho­oseOurs
Select the current changes
ct or :GitCo­nfl­ict­Cho­ose­Theirs
Select the incoming changes

Spectre

leader + s
open search panel
leader + sp
search in current file
leader + sw
search for selected word
When the search panel is opend we can use the following shortcuts:
enter
goto current file
dd
toggle current item
leader + R
replace all
leader + c
input replace vim command
leader + o
show option
leader + q
send all item to quickfix
leader + rc
replace current line
leader + v
change result view mode
th
toggle search hidden
ti
toggle ignore case
tu
update change when vim write file

Sorting

leader + so
sort visual selection

Search

space
search
control + space
backward search
leader + space
remove search highlights

Split Management

control + h
Move to existing or create a new split to the left of your current window + open file or custom command
control + j
Move to existing or create a new split to the top of your current window + open file or custom command
control + k
Move to existing or create a new split to the bottom of your current window + open file or custom command
control + l
Move to existing or create a new split to the right of your current window + open file or custom command

Session Management

:Sessi­onD­elete
Delete the current session
:Sessi­onLoad
Load the session for the current directory and current branch if git_us­e_b­ranch = true
:Sessi­onL­oadLast
Load the last session
:Sessi­onSave
Save the current session
:Sessi­onStart
Start recording a session. Useful if autosave = false
:Sessi­onStop
Stop recording a session
:Sessi­onT­oggle
Determines whether to load, start or stop a session
leader + sm
open saved session list

LSP Installer Commands

:LspIn­stall [--sync] [server]
instal­ls/­rei­nstalls language servers. Runs in a blocking fashion if the --sync argument is passed (only recomm­ended for scripting purposes).
:LspIn­sta­llInfo
opens a graphical overview of your language servers
:LspIn­sta­llLog
opens the log file in a new tab window
:LspPr­int­Ins­talled
prints all installed language servers
:LspUn­install [--sync]
uninstalls language servers. Runs in a blocking fashion if the --sync argument is passed (only recomm­ended for scripting purposes).
:LspUn­ins­tallAll [--no-­con­firm]
uninstalls all language servers

LSP Comman­ds/­Sho­rtcuts

K
Displays hover inform­ation about the symbol under the cursor in a floating window.
[ + d
Move to the previous diagnostic in the current buffer.
] + d
Move to the next diagno­stic.
control + k
Displays signature inform­ation about the symbol under the cursor in a floating window
gD
Jumps to the declar­ation of the symbol under the cursor.
gd
Jumps to the definition of the symbol under the cursor.
gi
Lists all the implem­ent­ations for the symbol under the cursor in the quickfix window.
gr
Lists all the references to the symbol under the cursor in the quickfix window.
space + ca
Selects a code action available at the current cursor position.
space + d
Jumps to the definition of the type of the symbol under the cursor.
space + e
Show diagno­stics in a floating window.
space + f
Add buffer diagno­stics to the location list.
space + rn
Renames all references to the symbol under the cursor.

Gitlinker

leader + gy
generate shareable file permalinks (with line ranges)

Diffview

:Diffv­iew­Close
generate shareable file permalinks (with line ranges)
:Diffv­iew­Fil­eHi­story
Opens a new file history view that lists all commits that affected the given paths.
:Diffv­iewOpen
Open Git Diffview Tab
:Diffv­iew­Refresh
Update stats and entries in the file list of the current Diffview

Git Worktree

leader + gw
To bring up the telescope window listing your workspaces
leader + gwn
To bring up the telescope window to create a new worktree

Comment

gb
Toggles the region using blockwise comment in visual mode
gbc
Toggles the current line using blockwise comment in normal mode
gc
Toggles the region using linewise comment in visual mode
gcc
Toggles the current line using linewise comment in normal mode

Comments

No comments yet.

Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.