DEV Community

Cover image for Getting Started with Vim Editor in Linux
Harvey
Harvey

Posted on

Getting Started with Vim Editor in Linux

Vim, the ultimate text editor for developers is one of the most popular and powerful text editors. The Vim Editor is used by a number of coders, programmers or developers in all platforms.

Vim is a command line text editor. Vim is available in almost all Linux distributions by default 😁 It is the best text editor when it comes to editing code. But if you are new to Linux and Vim, then this can be intimidating at first.

vim editor

If you are new to vim, I recommend these exercises

Start with vim

What makes Vim so efficient is that it leverages a powerful modal editing style. In modal editing, the editor works in two modes: you're either inserting text (insert mode i), or in command mode (ESC). This gives you a great deal of flexibility, as well as enabling some very fast movements and edits.

The most important commands are:

  1. Editing: i inserts text .
  2. Deleting: dd deletes a line
  3. Command mode: ESC
  4. Moving: "l" moves the cursor one character to the left, "h" to the left, "j" to below, "k" above, "l" to the right, "H" to the right, and "L" to the beginning of the line and column.

The following is a list of some essential and commonly used vim commands.

Action Command
vim file Open file
:w Save file
:wq Write and quit
:q! Quit without saving
h move cursor left
j move cursor down
k move cursor up
l move cursor right
yy copy line
p paste
!ls run ls command

Each command can be prefixed with a number to repeat it that many times over, for example :2wq will save the file and quit vim twice. Pressing 10j will move the cursor down 10 lines.

Top comments (0)