[ale] VI

David S. Jackson dsj at sylvester.dsj.net
Sat Jun 28 17:56:37 EDT 2003


On Fri, Jun 27, 2003 at 08:16:45AM -0700 tom hawks <tomhawks801 at yahoo.com> wrote:
> Probably a simple question. Say i am using a bunch of
> &nbsp;, what is the command in vi where I dont have to
> type in the whole phrase, just a keystroke or
> something?

As you've heard so far, there're lots of ways to do it.  You
could also use the :ab command, either on the fly or in your
.virc .exrc or whatever.  

:ab abbr sequence

Example:  :ab Hnb &nbsp;

You turn it on by typing the above in command mode and turn it
off by typing :unab Hnb in command mode.

(Note, you want to pick something you wouldn't normally find in
text, because *every* instance of that string will be translated
to &nbsp;  I chose "H" for html.  Hopefully you'll never need to
type "Hnb" in real life typing otherwise.)

There's the :map! x sequence method as has been explained.

There's the yank / paste method as has been explained.  This can
be used with named memory buffers with the double quote key.  Vi
allows you to store stuff in each of the 26 letters of the
alphabet for 26 named buffers.  (Ex: put &nbsp; on a line by
itself and type "xyy.  This stores "&nbsp;" in a named buffer
that can be recalled by typing "xP or "xp    Notice you're using
the double quote here as part of the command.)

Use the . repeat the last command or use a numberid prefix for
the number of times to execute before the command while in
command mode.  Ex: 4dd will delete 4 lines from where the cursor
is.

You can also store commands in named memory buffers and execute
them with the @ symbol.  Example: type i&nbsp;^[ on a line by
itself (the ^[ comes from Ctrl-V Esc).  Store it in a named
buffer with with "xyy     Now when you type @x it will execute
the command stored in the buffer.

You could also pick a unique character string for your string,
like "backspace-entity" or just "nbs-ent" and replace it later
with a global search and replace command.  (It's just a thought.)

You could put some sequences into a directory (like ~/.vimstuff
or something) and read them into your file with :r filename
followed by N. where N is the number of times you want to insert
it.  Put &nbsp; in ~/.vimstuff/ents/nbs and go :r $ent/nbs where
$ent resolves to $HOME/.vimstuff/entities.  (Okay, so I'm
reaching here, but hey, I'm on a roll.)

Some popular vi clones support sophisticated macro recording
devices.  Vim uses "qq" for example.

Okay, there are probably more ways, but this hopefully whets your
whistle.  Vi is just amazing. Sorry I got carried away.  Wheeeeee...

-- 
David S. Jackson                        dsj at dsj.net
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
In like a dimwit, out like a light.
		-- Pogo
_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale





More information about the Ale mailing list