[sclug] Vim Query

Bob Dunlop bob.dunlop at xyzzy.org.uk
Sat May 27 11:51:26 UTC 2006


On Sat, May 27 at 10:56, Glyn wrote:
> I guess this is to do with me not understanding something pretty basic about how Vim works, but I'm still scratching my head. I'm determined to make progress with Vim and any help in expediting my learning would be much appreciated,

The editor you use is unimportant so long as it leaves the text as simple
flat ASCII so avoid things that call themselves word processors.  I've been
a Vi user for well over 20 years so this seems trivial to me and I guess
you've missed the point somewhere.  This is what I did,  blow by blow in
the hope that it'll light the spark somewhere.

I use nvi by the way but Vim should be the same at this level.

First at the command prompt in an X-term (I'm assuming you're using X as
otherwise it's going to be difficult to view the web site at the same time
and different techniques will be required) I started to edit a new file with
the command:

  $ vi newfile.html

newfile is just the first name that came to mind and .html is the obvious
extentsion since that's the file type we wish to create.

Vi when it starts up will be in command mode, it's a moded editor so you
have to keep track of what mode it's in which is not as hard as it sounds
as there are only three basic modes.  To switch into insert mode for this
task press the "i" key for the insert command.  Any further input will be
inserted into the document since you are in insert mode.

Now in your browser window (I use firefox) find the web page with the text
you wish to cut and paste.  Position the cursor on the top left of the
text and holding the left mouse button down drag the cursor to the bottom
right of the text.  The text should be highlighted as you do this.  When
happy with your selection release the left button.

Switch focus back to your vi window and paste the text in by clicking the
middle button of your mouse.  If you have a broken mouse with only two
buttons the same effect is usually achieved by clicking both buttons
together.  You should now see your text pasted into the document.

The editor is still in insert mode remember.  To write the file out you
need to return to command mode.  To do this press the ESC key, this will
terminate insert mode and return the editor to command mode.  You only
need to press ESC once,  I've seen people in the habit of pressing ESC
before every command which while safe is wasteful of typing time.

At this point to save the file and exit vi press "Z" twice.  I think they
used Z as the last letter of the alphabet as the last command you should

ps.  The cut and paste that we've performed here is actually a function of
X-windows and not the Vi or Browser applications.  As such it can be used
between most X-windows apps.  I often use it to cut commands out of a
document I'm editing and paste them into shell for testing.

        Bob Dunlop

More information about the Sclug mailing list