Sunday, August 23, 2009

Re: Suggest a vim task for a college workshop

> The second task has been, for the past 2 years, writing a small C
> program and compiling it "from vim", using :!. I think we can do
> something a bit more exciting than that. Care to suggest something?

Powerful search/replace is a big one: A simple start is just
being able to use the EOL marker to add commas to a list of items:

:%s/$/,

(a not-so-simple task in most editors) and then perhaps joining
the whole list of them onto one line:

:%j

Manually changing a list of items (one-per-line) to a
comma-separated list on one line isn't a big deal when you have
less than 20 items or so, but when your list of items is several
hundred, the rapid gains provided by two commands (or even one,
if you like ":%s/\n/, /g") have saved folks hours of work. "End,
comma, space, delete, end, comma, space, delete, end, comma,
space, delete..."

One of the biggest "oooh"s I've gotten from folks who have seen
me use Vim at work involves the advanced search/replace
transformations with tagged elements -- things that would take
them hours to do by hand. So learning to use capture groups with
"\(...\)" and then referencing those in the replacement with
"\1".."\9" are big wins over most other editors.

One of the other big wins I've noticed people "ooh" at involve
text objects. Things like

ci"

to change the content of a string regardless of where I am in the
string; or using

yi(

to copy the contents of the surrounding parens for later pasting.

Anyways, showing people how they can use vim to be lazy is a big
plus in my book :-)

-tim

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

No comments: