The Basics

Neovim is a modern fork of Vim with enhanced features for efficient text editing and coding. I’m a long-time Vim user who switched to Neovim because it enhances my existing workflows. Many of the commands and workflows listed here are compatible with both Vim and Neovim. If you’re using Vim, refer to a vanilla Vim article to avoid confusion.

Some of the advantages of using Neovim over Vim are:

  • Better plugin architecture, including asynchronous plugins, native LSP support, and lua-first configuration.
  • Advanced syntax highlighting, including tree-sitter.
  • True color support.
  • And, most importantly, it has a livelier community.

You can get Neovim from the official website.

Primary Use Cases

  • Editing text files with speed and precision
  • Writing and maintaining code efficiently
  • Managing files and directories
  • Navigating your IDE with minimal hand movement through optimal keybindings

Less Suitable Use Cases

  • Editing binary files (use specialized tools instead)
  • Writing prose (consider dedicated writing tools)
  • Navigating the web (use a web browser)
  • Running scripts (use a terminal)
  • Managing processes (use system monitoring tools)

Command Reference

  • h - Move left
  • j - Move down
  • k - Move up
  • l - Move right
  • $ - Go to the end of the current line
  • ^ - Go to the beginning of the current line
  • G - Go to the end of the file
  • gg - Go to the beginning of the file
  • w - Move to the next word
  • b - Move to the previous word
  • { - Move to the previous line
  • } - Move to the following line
  • Ctrl-u - Scroll up half a page
  • Ctrl-d - Scroll down half a page
  • Ctrl-b - Scroll up one page
  • Ctrl-f - Scroll down one page

Window Commands

  • :new filename - Create a new window (and file if filename provided)
  • :split - Split the window horizontally
  • :vsplit - Split the window vertically
  • :q - Close the current window
  • Ctrl-w s - Split the window horizontally
  • Ctrl-w v - Split the window vertically
  • Ctrl-w w - Cycle through all windows
  • Ctrl-w q - Close the current window

Tab Commands

  • :tabnew - Create a new tab
  • :tabnext - Move to the next tab
  • :tabprevious - Move to the previous tab
  • :tabclose - Close the current tab
  • gt - Move to the next tab
  • gT - Move to the previous tab
  • 1gt - Move to the first tab
  • 2gt - Move to the second tab

File Commands

  • :! mkdir directory - Create a new directory
  • :! touch filename - Create a new file
  • :edit filename - Edit a file
  • :e filename - Edit a file
  • :write - Save the file
  • :w - Save the file
  • :x - Save and exit
  • :exit - Exit
  • :q - Exit

Directory Commands

  • nvim . - Open the current directory
  • :pwd - Print the current working directory
  • :cd /path/to/directory - Change the current working directory
  • :Explore - Open the file explorer
  • d - Create a new directory (in Explore)
  • % - Create a new file (in Explore)

Editing Commands

File Operations

  • dG - Delete to the end of the file
  • dd - Delete the current line

Paragraph Operations

  • d( - Delete to the end of the current paragraph
  • d) - Delete to the beginning of the current paragraph

Block Operations

  • d{ - Delete to the end of the current block
  • d} - Delete to the beginning of the current block
  • d/^$ - Delete from the cursor to the following empty line (if cursor is at the start of the block)

Word Operations

  • diw - Delete inner word (only the word, no surrounding spaces)
  • daw - Delete a word (the word and any trailing space)
  • dw - Delete from the cursor to the start of the next word
  • db - Delete from cursor back to the start of the previous word
  • dib - Delete inner “big word” (non-blank delimited WORDs)
  • daB - Delete a “big word” and trailing space

Sentence Operations

  • d[ - Delete to the end of the current sentence
  • d] - Delete to the beginning of the current sentence

General Operations

  • p - Paste the deleted text after the cursor
  • P - Paste the deleted text before the cursor
  • u - Undo the last change
  • Ctrl-r - Redo the last change
  • Ctrl-g - Show the current line and column

Configuration Commands

  • :help runtimepath - Review your config
  • :h rtp - Review your config
  • gx - Open links

Where Does Neovim Look For Config Files?

$HOME/.config/nvim/init.lua

What Language Is Used To Write Config Files?

It uses the Lua programming language, which provides better performance and more modern features than VimScript.

How Do I Review My Config?

:help runtimepath or :h rtp

How Do I Add A Custom Config?

Update the init.lua file with the following:

require('my_config')

Consider using Lazy.nvim to simplify the management of your plugins. It’s a plugin manager that allows you to easily install, update, and remove plugins and provides sensible defaults.

How Do I Add A Plugin?

Download the plugin and place it in the ~/.config/nvim directory.

Update the init.lua file with the following:

require('markdown-preview')

Select the link and press:

gx

Learn Neovim - Beyond the Basics

References