Monday, August 8, 2011

Re: Problem

On Mon, 8 Aug 2011, Tim Chase wrote:

> On 08/08/2011 05:10 PM, flipxfx wrote:
>> What does this do in Vim?
>>
>> q'a^i--[esc]jma^2xq
>
> [start recording a macro into register "a"]
>
> insert "--" at the beginning of the line.
>
> go down one line
>
> drop the mark named "a" here
>
> go to the first character on the line
>
> delete the first 2 characters
>
> [stop recording the macro]
>
>> Figure it out and you win!
>
> Now as to *why* one would want to do all this, it's a bit hard to tell
> without the text it's expected to be run over. Additionally, the macro
> is recorded, but never played back.

If the macro were already recorded, and there were already an 'a' mark,
it might be used to successively comment out one line of SQL and
uncomment the next, then the next time it was run, it would uncomment
the next line.

So:

type @a
then run the file
type @a
then run the file

-- is the ANSI style of SQL comment.
-- is also a comment mark in Lua, and undoubtedly other languages.
-- From grepping in NERD_commenter, these filetypes:
-- ada, ahdl, applescript, asn, catalog, csp, eiffel, gdmo, lace, lua,
-- mib, occam, plsql, sa, sather, sgmldecl, sql, sqlforms, sqlj, stp,
-- vhdl

Still not quite clear how generally useful this might be.

--
Best,
Ben

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: