Categories
blog Linux Ubuntu

60 second vi intro

vi is neat.  Most of the engineers I work with like nano or pico but I like vi.  For some reason it makes me feel more like a geek when I’m using it.  In fact, I’ve been using it so often lately that I have been trying to use vi command in notepad (obviously without success).  This tutorial will cover only the basics but that should be enough to get you started.  A much better tutorial is available here.

vi /etc/network/interfaces - opens /etc/network/interfaces in vi

i - insert
/ - search
G - [Shift] g - go to bottom of page
dd - delete the line
d <- or d -> - d [left or right arrow] delete 1 character in that direction
10G - 10 [Shift] g - move to line 10 (obviously number can be replaced)
10dd - delete 10 lines from cursor and below (again, number can be changed)
:q - quit (no changes may have been made)
:q! - quit (do not save changes)
:wq - write quite (save and quit)
:w - write (save)

Ok, now that you have mastered the basics of vi, please refer all other needs to the link provided above.  Hope you like vi as much as I do.

NOTE:  Ubuntu (and maybe debian) have a few things that the built in vi program have that seem a little strange.  I usually install vim just to be safe.  to do this run sudo apt-get install vim-full.

Leave a Reply

Your email address will not be published. Required fields are marked *