Learning vi - was Re: [Gllug] Linux Roadshow

William Palfreman william at palfreman.com
Sat Dec 8 04:07:33 UTC 2001


On Fri, 7 Dec 2001, Ian Scott wrote:

> >I know how you feel I moved from M$ to Linux some time ago and found the 
> >change confusing at first.  I don't know if it will work for you but I 
> >found my skills increased faster using the command line rather than 
> >learning loads of different GUI like Swat and linuxconfig to make life 
> >easier, suddenly all I had to learn was Bash and Vi.

I agree.  Everything else follows.
 
> In my experience, the GUI tools can be handy (eg. setting up a dialup
> connection with kppp is easier than ppp and chat) 

Nah.  pppd /dev/ttyS0 115200 user billp connect "/usr/sbin/chat -v '' AT
OK ATM0 OK ATD020812345678 CONNECT '\d\c'"

What could be easier?  Before I knew how to shell-script or use rc.local
that used to be in the bash history of my firewall's root account,
along with what ipchains rule to use post-boot.

> - but they tend to be limited.  Also, because they are newer, I
> often find they are less well documented (certainly KDE 1 docs had a
> lot of holes in them - there are several useful features which are
> pretty well hidden!). With dyed-in-the-wool cmdline stuff, there's
> usually a fair amount of help info out there on the web.
> 
> Incidently, I love vi as much as the next geek, but it's a bit
> daunting for newbies - the whole mode thing confuses nearly everyone!

Not at all.  I can teach a newbie to use vi in two minutes.  

Me: To edit a file use the vi command.  It goes like this:

vi filename.ext

Newbie:  Oh.  So I put the file name after the vi.  

Me: Yes.  Don't forget to press space between the vi and the file name.  
Remember, if you can't remember what the file is called, use the ls
command to list the files in your directory.

Newbie: Ok.

Me: Now open the file.

Newbie:  Er...  

$ vi hello.c

Hmm, can't seem to write anything on screen.

Me: To go into insert mode press i.  Do that now.

Newbie:  Cool.  Now I can write stuff.

Me: Well done.  Now, to quit or save, first press Esc. to escape
from insert mode.

Newbie: Ok.

Me: Now press :w to save.

Newbie: Ok.

Me: Now press :q to quit.

Newbie: Ok.  Hey, I'm back at that $ sign.

Me: Yes, you've left the vi program.  Now do an ls to see what you
file was called and load it into vi again.

Newbie:  Er... [looks at notes]

$ ls
hello.c

[looks at notes again]

$ vi hello.c

[looks at notes.  Presses i.  Does a little edit]

Me: Now I want you to put :w and :q together, for write-and-quit.  Press
:wq

[:wq appended to text]

Me: Don't forget to leave insert mode first by pressing Esc.

[Newbie backspaces over :wq in text, presses escape and carefully
presses :wq and enter]

Me: Well done.  There is a lot more to vi than that, but that's all you
need to know for now.

Newbie:  Ok.  Cheers.

> As a console text editor, the latest version of jed is pretty cool -
> drop down menus and stuff - you no longer need to learn loads of
> control key stuff before it's useful. If you're running X, there are
> plenty of newbie-friendly text editors out there - gnome and kde both
> have fairly good ones.

I find that after two minutes spent teaching them to use vi, they
voluntarily switch to a text console and use vi for all text editing.  
This is even more pronounced if you get wean them onto colourful vim
very early on.  Newbies love the coloured source code - it makes it come
alive.  To ensure they don't forget vi altogether, install vim on their
workstation, but make sure only vi is installed on your sacrificial
server.  Then they get used to editing source code with vim, but making
config changes with vi.  It is a short step from here to using vim in
preference and falling back on vi when vim is unavailable.

Regards,
Bill.

-- 
W. Palfreman. 		http://www.palfreman.com/william/
Tel: 0771 355 0354	PGP ftp://ftp.palfreman.com/pub/wfpkey.asc
			PGP id: 0x26C72581


-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list