DEV Community

Cover image for Basic Vim Commands Every Linux User Must Know

Basic Vim Commands Every Linux User Must Know

harvey profile image Harvey ・2 min read

Vim is the most popular text editor and the most powerful tool in Linux. And in order to master it, one must learn its basic commands.

Vim is one of the most interesting applications that any Linux user must learn at some point. It’s a very old text editor from the early days of UNIX, incredibly powerful and versatile, and fun to use 💻

Even if you’re not a developer or programmer, Vim is still an essential tool that you should learn if you use Linux or BSD on a daily basis.

If you are new to Vim, I recommend these exercises

What are modes?

Vim has two modes: normal mode and insert mode.

In normal mode, you can navigate through a text file and perform actions like delete, copy, paste, search, etc.

In insert mode, you can type or edit text. You can toggle between these modes by pressing the i or esc keys.

Must-know commands

So, here are a few basic command line options every Linux user must know.

  • Navigate text with the arrow keys (insertion mode)
  • To escape from insert mode press the Esc key. Then you can use the keys (h,j,k,l) as alternative to the arrow keys

  • If you want to move by word, you can use w and e. The w stands for word ahead while e stands for word end.

  • If you ever need to delete a sentence without deleting the whole text, you can type dd which deletes the whole line.

  • Then, there is J which joins lines if you have a single-line paragraph

  • The last basic command is :wq which saves your file and closes Vim. To quit without saving press :q!

  • Use the command :w to save the file

Terminal or GUI?

Vim, like many other Linux applications, has both a command line and a GUI (gvim) version. The GUI version has been included with most Linux distributions for years but many users stick to the more familiar command line version.

This year I used a variety of operating systems (Linux, Mac, RouterOS) and vi/vim is always available. Even on the most limited devices I connect to over ssh.

Vim is often called a "programmer's editor," and so useful for programming that many consider it an entire IDE. It's not just for programmers, though.

vim emmet

You can also use this to edit configuration files and perform several other tasks from in the terminal.

Vim is available in most Linux desktop distributions. It's based on vi which is available on even older or limited systems.

So if you're a Linux user, chances are that you came across vim in your adventures around the terminal.

Discussion (0)

Forem Open with the Forem app