Wednesday, January 9, 2013

Re: Please explain Regex




On Wed, Jan 9, 2013 at 7:25 AM, vicky b <vickyb2084@gmail.com> wrote:
Hello All,

  Recently i cam across this command :g /^/m0   which   reverses order o line can any body explain how  this works

:g without a range specified will operate on each line in the buffer starting at the top and moving to the bottom.

The pattern /^ says match at the start of a line, so it will match every line in the buffer.

/m0 says, "m"ove the line I am on to line 0 (the top of the buffer).

So, line 1 moves to the top.
line 2 moves to the top.
line 3 moves to the top.

Eventually, the file is reversed.

HTH,
David

--
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: