> What is your favorite little-known Vim feature?

One person's "little-known" feature is another person's
life-blood. :)

There are dark corners and abuses of Ex commands that I exercise
on a regular basis without thinking--when I mention them in an
answer on the list, I occasionally get a "wow, I didn't know that
about Vim" response.

Things like:

-using "*" to repeat the ex-range "'<,'>" so you don't have to
retype type 5 chars

        :*s/foo/bar
        is the same as

        :'<,'>s/foo/bar

-doing complex things with ":g"/":v" commands and the ranges that
follow

-text objects.  If you don't know 'em, learn 'em!

-dark corners of the regexp engine...especially back-references
if you've never used them before; and the power of the ":s"
command, along with the "\=" replacement for expression evaluation.

-the ability to sort a range/file by a found regexp rather than
just from the beginning of the line, or a fixed-column offset

Many of the "little-known" features are somewhat obvious upon
thinking about it, but it takes the little push of "Oh, I didn't
know you could combine X with Y and get such powerful behaviors!"
 Vim's "{count}{operator}{motion}" syntax means that if you learn
a new {operator}, you can apply pretty much every {motion} you
know to that command.  And vice-versa, if you learn a new
{motion}, suddenly you can start using it with all the
{operator}s that you already have.

Those are some of my top items.  Many folks know them and use
them regularly, but they're definitely indicators of a "vim power
user".

To read up,

        :help cpo-star
        :help :g
        :help :range
        :help :sort
        :help text-objects
        :help sub-replace-special
        :help motion.txt
        :help operator
        :help motion

-tim



Reply via email to