A A
RSS

Unix/Linux 101 – vi

Sat, Jan 5, 2008

Unix/Linux

Appendix A: vi

Most artists who use the Unix/Linux environment use IRIX. Under the X-windows (the graphic desktop) most prefer to use “jot” as their text editor. However, there are times when you need to use a text-only text editor with no graphics at all. This is useful when you want to telnet to another machine (remotely log on), and cannot use any graphics. Jot is a graphic text editor. There are two main text-only text editors – emacs and vi. Since I never use emacs I’ll briefly talk about vi.

Vi is a very complex text-editor with many commands and navigation keys. For a full listing of the vi commands type “man vi” To execute vi, either type:

# vi

or add the name of the file you want to edit or create:

# vi newfile.txt

vi has 3 main modes:

1.Insert mode – where you insert, append, change and replace text
2.Ex mode – Using ex (the line editor) commands
3.Command mode – this is the mode vi starts with.

You switch to other modes from this mode. I will show only a few of the important, most common, keys – there are too many keys to cover them all here:

<ESC>- the escape key is used to exit the Insert mode
: – the colon is used to enter the ex mode

Moving around

Arrow Keys – use the Up, Down, Right and Left. Also the “j,k,l,;” keys
w – Forward one word
b – backward one word
^F - page down
^B - page up
G – last line of file
5G – move to 5th line

Inserting Text

a – append after cursor
i – insert before cursor
o – open a line below current line
O – open a line above current line

Deletion

x – delete current character
dw – delete current word
dd - delete current line
5dd – delete 5 lines

Changing Text

r - replace one character
R – overwrite text in insert mode

Other

u - undo the last change
/string – move cursor to occurrence of string
:w – write the file using the same name
:w filename – write under a new name
:wq – write the file and quit
:ZZ – save all and quit
:q! – quit without saving

Tags: , , ,

Leave a Reply

You must be logged in to post a comment.

Become Our Fan!

Ad Ad

Contact us!

Have something to say? Want to contribute? Want something featured? Let us know! We are still working on our mind reading skills, so feel free to email us: info (at) thescratchpost (dot) com We would love to hear from you!!!
Rss Feed Tweeter button Facebook button Technorati button Reddit button Linkedin button Webonews button Delicious button Digg button Stumbleupon button Newsvine button