Basic Commands for Neovim

Learn some basic commands to use in Neovim.

all

What is Neovim?

Neovim is a text editor that runs in the terminal, an enhanced version of Vim designed to improve user experience and ease of maintenance. It is very, very fast. Many people, including myself, say “Once you try Neovim, there’s no turning back.”

It is a powerful text editor with many features, but don’t worry, you don’t need to know them all to use it. Over time, you’ll learn them. Moreover, you can customize it to your liking with plugins, themes, etc.

To use Neovim, you first need to install it. You can learn how to do it in the following link. This will install Neovim completely clean, without any plugins or anything, just the editor. Configuring Neovim is a whole different world. However, you can choose to use LazyVim, which is a Neovim configuration that comes with plugins, themes, etc. This way, you’ll save a lot of configuration time and can go straight to using it. There are many other configurations, but I recommend LazyVim to start getting familiar. This is my Neovim configuration if you want to check it out: My nvim setup.

You may feel a bit lost when using it, but don’t worry, I’ll teach you some basic commands to get you started.

Neovim Modes

You should know that Neovim has different modes, which are:

I have a plugin that shows me the mode I’m in, but if you don’t have it, you can see it in the bottom left corner; it will show you the mode you’re in:

Commands

Basics:

CommandDescription
iEnter Instert mode
EscExit any mode and enter Normal mode
vEnter Visual mode
:Enter Command mode
oCreate a new line below the cursor and enter Insert mode
OCreate a new line above the cursor and enter Insert mode
zzCenter the cursor on the screen
uUndo changes
Ctrl + rRedo changes
:qExit Neovim
:wSave changes
:wqSave changes and exit Neovim
CommandDescription
hMove the cursor to the left
jMove the cursor down
kMove the cursor up
lMove the cursor to the right
0Move the cursor to the beginning of the line
$Move the cursor to the end of the line
%Move the cursor to the next pair of characters, like: (), {}, []
Ctrl + eScroll down
Ctrl + yScroll up
ggMove the cursor to the beginning of the document
GMove the cursor to the end of the document
wMove the cursor to the beginning of the next word
bMove the cursor to the beginning of the previous word
eMove the cursor to the end of the next word
Ctrl + uScroll the screen several lines up
Ctrl + dScroll the screen several lines down

Conversion:

CommandDescription
veUConvert the selection to uppercase
veuConvert the selection to lowercase

Operations:

CommandDescription
4jMove the cursor 4 lines down
6kMove the cursor 6 lines up

Text Selection:

CommandDescription
viwSelect the word under the cursor
vecReplace from the cursor position to the end of the word, and enter Insert mode
ciwReplace the word under the cursor and enter Insert mode
yiwCopy the word under the cursor
diwDelete the word under the cursor and enter Normal mode
vi(Select the content between parentheses. (Works with any pair of characters)
ci”Replace the content between double quotes, and enter Insert mode. (Works with any pair of characters)
va(Select the content between parentheses and the parentheses. (Works with any pair of characters)
da(Delete the content between parentheses and the parentheses, and enter Normal mode. (Works with any pair of characters)
ca”Replace the content between double quotes and the quotes, and enter Insert mode. (Works with any pair of characters)

Copy, Paste, and Cut:

CommandDescription
yyCopy the line under the cursor
ddCut the line under the cursor
pPaste what’s in the clipboard on the line below the cursor
PPaste what’s in the clipboard on the line above the cursor
xCut the character under the cursor
vyCopy the character under the cursor

Search and Replace:

CommandDescription
/Search for the word you type throughout the document
nSearch for the next occurrence
NSearch for the previous occurrence
fhSearch for the first occurrence after the cursor for the letter h. (Works with any character)
FhSearch for the first occurrence before the cursor for the letter h. (Works with any character)
rReplace the character under the cursor with the character you specify
#Search for the word under the cursor
*Search for the word under the cursor
:%s/aaa/bbbb/gReplace all occurrences of aaa with bbb throughout the document

Ready, with these basic commands, you can navigate well in Neovim. Enjoy! 😃