Neovim Cheatsheet

Press ESC to return to Normal mode

Movement

h j k l Move left, down, up, right
w b Move to next/previous word
0 $ Move to start/end of line
gg G Move to top/bottom of file
{ } Move to previous/next paragraph

Modes

i Insert mode
a Append after cursor
o O Open new line below/above
v V Visual mode / Line visual mode
ESC Return to Normal mode

Editing

x Delete character under cursor
dd Delete entire line
dw Delete word
yy Copy (yank) line
yw Copy word
p P Paste after/before cursor
u Undo
Ctrl + r Redo

Search & Replace

/pattern Search forward
?pattern Search backward
n N Next/previous search result
:%s/old/new/g Replace all in file

File Operations

:w Save file
:q Quit
:wq Save and quit
:q! Quit without saving
:e filename Open file

Windows & Tabs

:sp Split window horizontally
:vsp Split window vertically
Ctrl + w w Switch between windows
Ctrl + w q Close current window
:tabnew Open new tab
gt gT Next/previous tab

Essential Commands

. (dot) Repeat last command
>> << Indent/unindent line
=G Auto-indent entire file
:set number Show line numbers
:set relativenumber Relative line numbers

Basic init.lua Configuration

Place this in ~/.config/nvim/init.lua for a clean, basic Neovim setup
-- Basic Neovim Configuration

-- Enable essential settings
vim.opt.number = true                    -- Show line numbers
vim.opt.relativenumber = true           -- Relative line numbers
vim.opt.tabstop = 4                     -- Tab width
vim.opt.shiftwidth = 4                  -- Indentation width
vim.opt.expandtab = true                -- Use spaces instead of tabs
vim.opt.smartindent = true              -- Smart indentation
vim.opt.wrap = false                   -- Don't wrap lines
vim.opt.mouse = 'a'                     -- Enable mouse support
vim.opt.clipboard = 'unnamedplus'        -- System clipboard
vim.opt.cursorline = true               -- Highlight current line
vim.opt.termguicolors = true           -- True colors support
vim.opt.background = 'dark'              -- Dark background

-- Search settings
vim.opt.ignorecase = true               -- Case insensitive search
vim.opt.smartcase = true                -- Case sensitive if uppercase used
vim.opt.hlsearch = false                -- Don't highlight search results

-- Split configurations
vim.opt.splitright = true                -- Vertical splits to the right
vim.opt.splitbelow = true                -- Horizontal splits below

-- Key mappings
vim.g.mapleader = ' '                   -- Space as leader key

-- Save file with Ctrl+S
vim.keymap.set('n', '', ':w', { noremap = true, silent = true })

-- Exit insert mode with jj
vim.keymap.set('i', 'jj', '', { noremap = true, silent = true })

-- Clear search highlighting with Space + /
vim.keymap.set('n', '/', ':nohlsearch', { noremap = true, silent = true })

-- Basic plugin manager (lazy.nvim) setup
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    'git',
    'clone',
    '--filter=blob:none',
    'https://github.com/folke/lazy.nvim.git',
    '--branch=stable',
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)

-- Essential plugins
require('lazy').setup({
  { 'nvim-telescope/telescope.nvim', dependencies = { 'nvim-lua/plenary.nvim' } },
  { 'nvim-treesitter/nvim-treesitter' },
  { 'tpope/vim-surround' },
  { 'nvim-tree/nvim-tree.lua' },
  { 'morhetz/gruvbox' }, -- Popular color scheme
})

-- Set colorscheme
vim.cmd('colorscheme gruvbox')

-- Telescope keybindings
vim.keymap.set('n', 'ff', ':Telescope find_files', { noremap = true, silent = true })
vim.keymap.set('n', 'fg', ':Telescope live_grep', { noremap = true, silent = true })
vim.keymap.set('n', 'fb', ':Telescope buffers', { noremap = true, silent = true })

-- NERDTree toggle
vim.keymap.set('n', 'n', ':NvimTreeToggle', { noremap = true, silent = true })