Vim tutorial for beginners

vim screenshotVim is an open source text editor that runs on Linux, MacOSX, Windows and many other operating systems. If I had to describe it in just one word, then the first thing I can think of would be “powerful”. Vim supports syntax highlighting for really almost any format and has got many other extras.

But “powerful” also describes the learning curve, because Vim can be fully controlled via the keyboard. There are tons of commands and shortcuts you can learn. But however, if you once learned how to handle Vim it is a wonderful tool. Just the fact that Vim can actually be found on nearly any Linux system, no matter where and under what distribution you are currently working, is a good reason to learn at least the basics of how to operate Vim. Therefore I wrote this mini-reference for Vim with the most necessary commands to start off using Vim.

Vim  – the basics

Vim can be started with the command “vi” or “vim”. If you want to open a file, write it’s name simple behind the vim command.

vim my_file.txt

When Vim has started, you are in normal mode. There are three modes in Vim: normal mode, insert mode and command mode. If you want to write “freely”, like you’re used to with other text editors,  you have to switch to insert mode. Nevertheless the normal mode also allows special operations for editing the file.

insert mode
i – switch to insert mode
Shift+a – moves the cursor to the end of the line and switches into insert mode
Esc – leave insert mode

normal mode
x – deletes the character under the cursor
r + any character – replace the character under the cursor with the given character
d d – deletes the current line
Shift+g – moves the cursor to the end of file

command mode
[key]:[/key] – opens the command mode (hereinafter directly integrated in the instructions)
:w – saves the file
:sav filename.extension- saves the file under the name filename.extension
:q – quits Vim
:q! – closes Vim also if changes have not been saved
:wq – saves the file and then closes Vim

Tipps & Tricks

copy & paste

v – changes to the visual mode
Move the cursor to select the desired area.
y – copies marked area
Use the cursor to select the point where you want to insert the copied text
p – pastes copied text

cut & paste

Cut and paste works almost like copying and pasting.
Just use d instead of  y if you want to cut instead of copy

Help / Command overview

:help – displays the Vim help including many commands
:q – closes the Vim help

3 Comments

  1. Your Bolg have Nice Info on Vim
    Checkout mine Vim tutorial Cheat Sheet , Learn VIM in 5 miunute
    https://www.youtube.com/watch?v=7BDh4bDqG8Y

Leave a comment

Please be polite. We appreciate that. Your email address will not be published and required fields are marked