Skip to content

Vim and Neovim ​

Vim Motions ​

Key(s)Meaning
iInsert
aAppend
oInsert on the next line
OInsert on the previous line
uUndo
wNext word
bPrevious word
eEnd of the current word
WNext whitespace-separated word
fFind the next character
FFind the previous character
tMove before the next character
TMove before the previous character
ggFirst line of the file
GLast line of the file
%Matching bracket or block
^First non-space character of the line
$End of line
0Start of line
pPaste
dDelete
rReplace one character
RReplace multiple characters
yYank or copy
vVisual mode
VVisual line mode
Ctrl + vVisual block mode
vi', vi", vi(, vi{, vi[, vi<Select inside a scope
va', va", va(, va{, va[, va<Select around a scope
Ctrl + dScroll down
Ctrl + uScroll up
Ctrl + rRedo
di(Delete inside parentheses
ci(Change inside parentheses

Macros ​

  1. q[register] starts recording, for example qa.
  2. Perform the actions you want to repeat.
  3. Press q again to stop recording.
  4. @[register] replays the macro, for example @a.

Useful shortcuts:

  • @@ replays the last macro.
  • 100@a runs macro a one hundred times.

Window Management ​

Use Ctrl + w first, then one of the keys below.

Key(s)Meaning
vSplit vertically
sSplit horizontally
h / j / k / lMove to another pane
left / right / up / downMove to another pane
H / J / K / LMove the pane itself
+Increase height
-Decrease height
<Decrease width
>Increase width
=Equalize pane sizes
cClose the current pane
oClose all other panes
_Maximize the current pane

Basic Vim Settings ​

vim
set tabstop=2 shiftwidth=2 expandtab relativenumber foldmethod=indent autoindent hlsearch incsearch
filetype plugin indent on
" colorscheme Monokai
syntax on

Neovim Setup Notes ​

  1. Create ~/.config/nvim/init.lua.
  2. Put plugin files in ~/.config/nvim/lua/plugins/.
  3. Add plugin-specific setup inside each plugin definition.
lua
config = function()
  -- do something here
end

Basic options and keymaps:

lua
vim.cmd("set expandtab")
vim.cmd("set tabstop=2")
vim.cmd("set softtabstop=2")
vim.cmd("set shiftwidth=2")

-- map leader to space
vim.g.mapleader = " "

vim.keymap.set("n", "<C-s>", ":w<CR>", { noremap = true, silent = true })
vim.keymap.set("i", "<C-s>", "<Esc>:w<CR>a", { noremap = true, silent = true })
vim.keymap.set("n", "<C-t>", ":tabnew<CR>", { noremap = true, silent = true })

Useful plugins to install:

  • lazy.nvim
  • telescope.nvim
  • nvim-treesitter
  • neo-tree.nvim
  • mason.nvim
  • mason-lspconfig.nvim
  • nvim-lspconfig
  • telescope-ui-select.nvim

Project-Specific Config ​

Create .nvim.lua at the project root when a repository needs local overrides.

lua
-- Project-specific config example

-- Set project-specific options
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
vim.opt.expandtab = true

-- Add keybindings specific to the project
vim.keymap.set("n", "<leader>pr", ":!npm run dev<CR>", { noremap = true, silent = true })

-- Configure plugins
if require("telescope") then
  require("telescope").setup({
    defaults = {
      file_ignore_patterns = { "node_modules", "dist/" }
    }
  })
end

print("Loaded project-specific Neovim config!")